mysql在linux上的安裝與配置
阿新 • • 發佈:2018-12-23
[[email protected] /]# vi /etc/hosts
192.168.68.136 mysql-server-01
service iptables status 檢視防火牆狀態
chkconfig iptables off 重啟後永久生效
yum -y install gcc gcc-c++
tar xzvf /usr/local/software/tar/mysql-5.6.39-linux-glibc2.12-i686.tar.gz -C /usr/local/software/
mv mysql-5.6.39-linux-glibc2.12-i686 mysql-5.6.39
cp mysql-5.6.39 /usr/local/mysql -r
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R root:root ./
chown -R mysql:mysql data
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql
./bin/mysqladmin -u root password 'mysqladmin'//要先解決如下的異常,然後重啟伺服器
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql//一定要執行,不然不能使用mysql命令
--------------------------------------------------------------------
錯誤異常的解決:
[ [email protected] mysql]# ./bin/mysqladmin -u root password 'mysqladmin'
./bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
檢視/tmp資料夾的確沒有mysql.sock檔案,
通過find命令查詢
[ [email protected] /]# find / -name mysql.sock
/var/lib/mysql/mysql.sock
原來安裝到/var/lib/mysql/mysql.sock這個位置啦,我們需要修改my.cnf檔案
[[email protected] /]# vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
儲存之後即出,重新啟動mysql。
service mysql restart
-------------------------------------------------------------------
mysql -uroot -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysqladmin' WITH GRANT OPTION;
FLUSH PRIVILEGES;
service mysql restart
192.168.68.136 mysql-server-01
service iptables status 檢視防火牆狀態
chkconfig iptables off 重啟後永久生效
yum -y install gcc gcc-c++
tar xzvf /usr/local/software/tar/mysql-5.6.39-linux-glibc2.12-i686.tar.gz -C /usr/local/software/
mv mysql-5.6.39-linux-glibc2.12-i686 mysql-5.6.39
cp mysql-5.6.39 /usr/local/mysql -r
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R root:root ./
chown -R mysql:mysql data
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql
./bin/mysqladmin -u root password 'mysqladmin'//要先解決如下的異常,然後重啟伺服器
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql//一定要執行,不然不能使用mysql命令
--------------------------------------------------------------------
錯誤異常的解決:
[
./bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
檢視/tmp資料夾的確沒有mysql.sock檔案,
通過find命令查詢
[
/var/lib/mysql/mysql.sock
原來安裝到/var/lib/mysql/mysql.sock這個位置啦,我們需要修改my.cnf檔案
[[email protected] /]# vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
儲存之後即出,重新啟動mysql。
service mysql restart
-------------------------------------------------------------------
mysql -uroot -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysqladmin' WITH GRANT OPTION;
FLUSH PRIVILEGES;
service mysql restart