cd /opt
mkdir mysql
cd mysql
#在/opt/mysql 拷贝mysql-server_5.7.21-1ubuntu17.10_amd64.deb-bundle.tar文件
sudo apt-get install libaio1
tar xvf mysql-server_5.7.21-1ubuntu17.10_amd64.deb-bundle.tar
#为root用户提供MySQL安装密码
sudo dpkg -i mysql-common_*.deb
sudo dpkg -i mysql-community-client_*.deb
sudo dpkg -i mysql-client_*.deb
sudo dpkg -i mysql-community-server_*.deb
sudo dpkg -i mysql-server_*.deb
#如果中途被dpkg警告未满足的依赖关系 ,可以使用apt-get来修复它们,然后再运行中断的命令 :sudo apt-get -f install
sudo service mysql start
sudo service mysql stop
sudo service mysql status
mysql -h 127.0.0.1 -P 3306 -uroot -p123456
show databases;
#允许root访问
update mysql.user set Host='%' where HOST='localhost' and User='root';
flush privileges;
nano /etc/mysql/mysql.conf.d/mysqld.cnf
#注释掉bind-address = 127.0.0.1
#设置最大连接数
bind-address = 127.0.0.1
#查看最大连接数
show variables like '%max_connections%';
mysql 5.7数据 如果出现
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
修改
/etc/mysql/mysql.conf.d# vim mysqld.cnf 文件 添加 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES