一、下載mysql-5.6.30-linux-glibc2.5-x86_64.tar.gzmysql
二、解壓到安裝目錄linux
#解壓
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gzsql
#添加目錄數據庫
mkdir -p /usr/local/mysql服務器
#複製解壓後的mysql目錄
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/socket
三、添加用戶組和用戶測試
#添加用戶組
groupadd mysql
#添加用戶mysql 到用戶組mysql
useradd -g mysql mysqlui
四、安裝this
1)、cd /usr/local/spa
2)、rename mysql-5.6.30-linux-glibc2.5-x86_64 mysql *
3)、cd /usr/local/mysql/
4)、mkdir -p ./data/mysql
5)、chown -R mysql:mysql ./
6)、./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql (錯誤1)
7)、cp support-files/mysql.server /etc/init.d/mysqld (錯誤2)
8)、chmod 755 /etc/init.d/mysqld
9)、cp support-files/my-default.cnf /etc/my.cnf
10)、 #修改啓動腳本
vi /etc/init.d/mysqld
11)、#修改項:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
12)、#啓動服務
service mysqld start
13)、#測試鏈接
./mysql/bin/mysql -uroot
14)、#加入環境變量,編輯 /etc/profile,這樣能夠在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin source /etc/profile
說明:
#啓動mysql service mysqld start
#關閉mysql service mysqld stop
#查看運行狀態 service mysqld status
備註:安裝過程遇到錯誤莫要慌張
錯誤一、FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
解決方法 :安裝autoconf庫 命令:yum-y install autoconf
錯誤二、Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
當咱們使用「mysql_install_db」安裝MySQL時,須要libaio包,現將不一樣Linux系統安裝該包的方式總結以下:
一、對於Redhat/CentOS系統用以下安裝方式:[root@dbhost01~]# yum install libaio
二、對Debian系統用以下安裝方式:root@dbhost01:~# apt-get install libaio1
遠程訪問注意事項:
遠程訪問時須要密碼安裝全程沒有設置過密碼就須要修改密碼了
中止msql服務
ps -ef|grep mysql
殺死進程 kill -9 8389
2.修改MySQL的登陸設置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存而且退出vi。
3.從新啓動mysqld
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登陸並修改MySQL的root密碼
# ./mysql/bin/mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
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 Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.將MySQL的登陸設置修改回來
# vi /etc/my.cnf
將剛纔在[mysqld]的段中加上的skip-grant-tables刪除
保存而且退出vi。
6.從新啓動mysqld
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
鏈接時,報1130錯誤,是因爲沒有給遠程鏈接的用戶權限問題
解決1:更改 ‘mysql’數據庫‘user’表‘host’項,從‘localhost’改爲‘%’。
use mysql;
select 'host' from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
解決2:直接受權
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
雲服務器端口沒開放問題