站長資訊網
        最全最豐富的資訊網站

        安裝MySQL5.7解析

        tar包解壓安裝

        一、檢查環境

          #卸載系統自帶的Mariadb  [root@Meng ~]# rpm -qa|grep mariadb  mariadb-libs-5.5.44-2.el7.centos.x86_64  [root@Meng ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64    #刪除etc目錄下的my.cnf文件    [root@Meng ~]# rm /etc/my.cnf  rm: cannot remove etc/my.cnf No such file or directory    #檢查mysql是否存在  [root@Meng ~]# rpm -qa | grep mysql  [root@Meng ~]#     #檢查mysql組和用戶是否存在,如無創建  [root@Meng ~]# cat /etc/group | grep mysql   [root@Meng ~]#  cat /etc/passwd | grep mysql    #創建mysql用戶組  [root@Meng ~]# groupadd mysql  #創建一個用戶名為mysql的用戶并加入mysql用戶組  [root@Meng ~]# useradd -g mysql mysql  #制定password 為222222  [root@Meng ~]# passwd mysql  Changing password for user mysql.  New password:   BAD PASSWORD: The password is a palindrome  Retype new password:   passwd: all authentication tokens updated successfully.    #安裝到/usr/local  [root@Meng local]# wget https://cdn.mysql.com//Downloads/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz  [root@Meng local]# tar -zxvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz  [root@Meng local]# mv mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz/ mysql    #更改所屬的組和用戶  [root@Meng local]# chown -R mysql mysql/  [root@Meng local]# chgrp -R mysql mysql/  [root@Meng local]# cd mysql/    [root@Meng mysql]# mkdir data    [root@Meng mysql]# chown -R mysql:mysql data

        二、配置文件

          [root@Meng mysql]# vim my.cnf
          [mysql]  # 設置mysql客戶端默認字符集  default-character-set=utf8   [mysqld]  skip-name-resolve  #設置3306端口  port = 3306   # 設置mysql的安裝目錄  basedir=/usr/lcoal/mysql  # 設置mysql數據庫的數據的存放目錄  datadir=/usr/lcoal/mysql/data  # 允許最大連接數  max_connections=200  # 服務端使用的字符集默認為8比特編碼的latin1字符集  character-set-server=utf8  # 創建新表時將使用的默認存儲引擎  default-storage-engine=INNODB   lower_case_table_names=1  max_allowed_packet=16M

        點擊Esc,輸入:wq 保存并退出!

        三、安裝和初始化

          [root@Meng mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
          [root@Meng mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld  [root@Meng mysql]# chown 777 /etc/my.cnf   [root@Meng mysql]# chmod +x /etc/init.d/mysqld
          [root@Meng mysql]# /etc/init.d/mysqld restart  Shutting down MySQL.. SUCCESS!   Starting MySQL. SUCCESS!     #設置開機啟動    [root@Meng mysql]# chkconfig --level 35 mysqld on  [root@Meng mysql]# chkconfig --list mysqld    [root@Meng mysql]# chmod +x /etc/rc.d/init.d/mysqld  [root@Meng mysql]# chkconfig --add mysqld  [root@Meng mysql]# chkconfig --list mysqld  [root@Meng mysql]# service mysqld status   SUCCESS! MySQL running (6666)

        四、配置環境變量

          [root@Meng ~]#vim /etc/profile

        安裝MySQL5.7解析

        一定要配置好!!!

        不然會出現已安裝 MySQL,但執行 mysql 命令提示命令找不到的問題!

        五、登陸數據庫

        1、獲得初始密碼

          [root@Meng bin]# cat /root/.mysql_secret  

        2、修改密碼

          [root@Meng mysql]# mysql -uroot -p  Enter password:   Welcome to the MySQL monitor.  Commands end with ; or g.  Your MySQL connection id is 3  Server version: 5.7.23    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.    Oracle is a registered trademark of Oracle Corporation and/or its  affiliates. Other names may be trademarks of their respective  owners.    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.    mysql> set PASSWORD = PASSWORD('meng_2018');  Query OK, 0 rows affected, 1 warning (0.00 sec)    mysql> flush privileges;  Query OK, 0 rows affected (0.00 sec)

        3、添加遠程訪問權限

          mysql> use mysql  Reading table information for completion of table and column names  You can turn off this feature to get a quicker startup with -A    Database changed  mysql> update user set host='%' where user='root';  Query OK, 1 row affected (0.00 sec)  Rows matched: 1  Changed: 1  Warnings: 0    mysql> select host,user from user;  +-----------+---------------+  | host      | user          |  +-----------+---------------+  | %         | root          |  | localhost | mysql.session |  | localhost | mysql.sys     |  +-----------+---------------+  3 rows in set (0.00 sec)    create user 'xxx'@'%' identified by '123';  這里 @‘%’ 表示在任何主機都可以登錄

        4、重啟生效

          mysql> quit  Bye  [root@Meng mysql]# /etc/init.d/mysqld restart   Shutting down MySQL.. SUCCESS!   Starting MySQL. SUCCESS! 

        5、在任何目錄下可以登錄mysql

          [root@Meng mysql]# ln -s /usr/local/mysql/bin/mysql   /usr/bin/mysql

        自己安裝了半天,最終才安裝成功!第一開始是用的yum安裝方式,但是總出現問題,最終選擇的壓縮包的方式,以此記錄,愿大家順利安裝!

        贊(0)
        分享到: 更多 (0)
        網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
        主站蜘蛛池模板: 久久久久久亚洲精品无码| 精品一区二区三区东京热| 日韩精品系列产品| 国产精品日韩深夜福利久久| 国产成人精品免费久久久久| 伊在人亚洲香蕉精品区麻豆| 国产精品1024在线永久免费| 国产精品免费AV片在线观看| 亚洲精品自在在线观看| 久久99精品久久久久久齐齐| 青青草精品视频| 91麻豆精品国产自产在线观看一区 | 日韩精品毛片| 国产精品嫩草影院一二三区| 亚洲精品在线观看视频| 国内精品手机在线观看视频| 国产乱码精品一品二品| 精品午夜福利在线观看| 香蕉久久夜色精品升级完成| 尤物TV国产精品看片在线| 日韩精品欧美激情国产一区| 蜜臀av无码人妻精品| 久久91精品综合国产首页| 国产亚洲精品无码专区| 国产精品热久久无码av| 成人国产精品日本在线观看| 91精品无码久久久久久五月天| 欧美+亚洲+精品+三区| 热re99久久精品国产99热| 日韩精品在线视频| 中文字幕亚洲精品| 中文字幕精品一区影音先锋| 91精品免费久久久久久久久| 99久久精品国产毛片| 国产精品人人做人人爽| 精品久久国产一区二区三区香蕉| 国产精品亚洲综合一区| 久久精品国产黑森林| 久热精品视频第一页| 亚洲精品无码久久毛片| 亚洲精品国产精品乱码视色 |