Linux下安裝mysql 5.7
1.上傳tar包到服務器並解壓tar包到/usr/local/目錄
cd /usr/local/
tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
2.創建運行MySQL的用戶和組(名字可以任意)
Shell> groupadd mysql
Shell> useradd mysql -g mysql
3.切換到mysql目錄
Shell > mkdir data
4.修改解壓包的權限
Shell> chown –R mysql
Shell> chgrp –R mysql
5.安裝MySQL
Shell> bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ##初始化數據目 錄
shell> cp -f support-files/my-default.cnf /etc/my.cnf ##將默認配置文件復制到指定目錄
shell> bin/mysqld_safe --datadir=/usr/local/mysql/data --user=mysql & ##啟動MySQL服務
shell> cp support-files/mysql.server /etc/init.d/mysql.server ##將MySQL加入到服務自啟動
Shell> /etc/init.d/mysql.server start ##通過服務啟動MySQL
啟動過程中如果碰到如下錯誤
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ? bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
則需要安裝包yum install -y libaio
初始化過程中獲得root的初始密碼
修改root的初始密碼
mysql> set password=password(‘mysql‘); ? Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges; ? Query OK, 0 rows affected (0.00 sec)
Linux下安裝mysql 5.7