https://www.cnblogs.com/silentdoer/articles/7258232.html
https://www.cnblogs.com/starof/p/4680083.html 参照网址
1、下载 Mysql yum包
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
2、安装软件源
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
3、安装mysql服务端
yum install -y mysql-community-server
4、首先启动mysql
service mysqld start(重启是restart,完全弄好MySQL后最好添加lower_case_table_names=1到[mysqld]下面一行然后重启MySQL,这是为了和windows兼容,还有就是在[mysql]下面一行加入default-character-set=utf8)
systemctl start mysqld.service(这个是上面步骤执行后自动输出的,我这边的全称是:Redirectingto/bin/systemctlstartmysqld.service)
5、接着检查mysql 的运行状态
service mysqld status
systemctl status mysqld.service(也是系统自动输出的,我这边全称是:Redirectingto/bin/systemctlstatusmysqld.service
6、登陆并修改密码
grep 'temporary password' /var/log/mysqld.log(如果之前安装过MySQL则这里可能会有多个密码,用最后一个,注意这个密码输入时是可以粘贴的)//查看安装好的默认的密码,以便后面可以登录
mysql -uroot -p(这是一个MySQL的以密码登录root用户的命令)
alter user 'root'@'localhost' identified by '数据库密码'; //(最好有;结尾)
如果报错:先进行一些数据库操作,select @@log_error;
如果还报错:set global validate_password_policy=0; //修改validate_password_policy参数的值
set global validate_password_length=1; // 再修改密码的长度
再进行修改密码
7、授权其他机器登陆
GRANT ALL PRIVILEGES ON*.* TO 'root'@'%' IDENTIFIEDBY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
8、数据库查看设置语句
mysql> show databases;
mysql>create user 'username'@'%' identified by 'password'; //新建用户
mysql > show global variables like 'port'; //查看mysql数据库的端口
mysql > select Host,user,Grant_priv,Super_priv from mysql.user; //查看mysql数据库所有用户以及权限
mysql>update user set host = '%' where user ='root'; //将root设置成可以其他地址可以连接
mysql> grant all privileges on *.* to 'lemon'@'%' identified by 'xxxxx' with grant option; //给新增的数据库用户赋值
(报错)ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
【解决:https://www.cnblogs.com/ivictor/p/5142809.html
mysql>set global validate_password_policy=0;
mysql>select @@validate_password_length;
mysql>set global validate_password_length=1;
mysql>select @@validate_password_mixed_case_count;
mysql>set global validate_password_mixed_case_count=2;
mysql>show variables like '%validate_password%'; //更改完设置,再重新给数据库新增的用户赋值
】
mysql> show full pocesslist; //查看连接数以及状态(root登录能看所有的连接,其他用户只能看自己的连接数)
【mysqladmin -uroot(用户名) -proot(密码) processlist ,全局查看】
mysql退出三种方法:
mysql > exit;
mysql > quit;
mysql > \q;
遇到的错误:
https://blog.csdn.net/guzarish/article/details/82701499