ubuntu16.04下安装 Mysql 5.6.40

1.卸载之前的安装包

sudo apt-get autoremove --purge mysql-server-5.*
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common

2.安装mysql依赖包

 sudo apt-get install libaio-dev
 sudo apt-get install libmecab2

3.下载mysql,解压

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-server_5.6.40-1ubuntu14.04_amd64.deb-bundle.tar
tar -xvf mysql-server_5.6.40-1ubuntu14.04_amd64.deb-bundle.tar mysql5.6.40
cd mysql5.6.40

4.安装mysql

sudo dpkg -i mysql-common_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient18_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-client_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-client_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-community-server_5.6.40-1ubuntu14.04_amd64.deb
sudo dpkg -i mysql-server_5.6.40-1ubuntu14.04_amd64.deb

5. 开启远程访问 ,修改/etc/mysql/mysql.conf.d/mysqld.cnf如下

[mysqld]
bind-address = 0.0.0.0

6.开启远程访问 

mysql -uroot -p
mysql>CREATE USER '自定义授权用户名'@'localhost' IDENTIFIED BY '自定义授权密码';
mysql>CREATE USER '自定义授权用户名'@'%' IDENTIFIED BY '自定义授权密码';
mysql>GRANT ALL ON *.* TO '自定义授权用户名'@'localhost';
mysql>GRANT ALL ON *.* TO '自定义授权用户名'@'%';
mysql>flush privileges;

7.连接测试

service mysql stop 
service mysql start

mysql -u root -p 

show variables like "char%"; 

show global variables like "%datadir%"; 查看MySQL安装的全局信息

 

你可能感兴趣的:(mysql)