centos 7 iso u盘安装_CentOS安装MySQL5.7
1.下载MYSQL的rpm包[root@VM_0_4_centos ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm2.安装MySQL的yum源[root@VM_0_4_centos ~]# yum localinstall mysql57-community-release-el7-8.noa
1.下载MYSQL的rpm包
[root@VM_0_4_centos ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安装MySQL的yum源
[root@VM_0_4_centos ~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检查MySQL的yum源是否安装成功
[root@VM_0_4_centos ~]# yum repolist enabled | grep "mysql.*-community.*"
4.修改默认安装的MySQL版本
[root@VM_0_4_centos ~]# vim /etc/yum.repos.d/mysql-community.repo [mysql-connectors-community]
5.安装MySQL
[root@VM_0_4_centos ~]# yum install mysql-community-server
6.启动MySQL并查看MySQL运行状态
[root@VM_0_4_centos ~]# systemctl start mysqld
[root@VM_0_4_centos ~]# systemctl status mysqld
7.设置MySQL开机启动
[root@VM_0_4_centos ~]# systemctl enable mysqld[root@VM_0_4_centos ~]# systemctl daemon-reload
8.查看MySQL安装的默认密码。
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
[root@VM_0_4_centos ~]# grep 'temporary password' /var/log/mysqld.log2019-05-18T03:55:53.402018Z 1 [Note] A temporary password is generated forroot@localhost: keIh:7roUido
9.修改MySQL密码
[root@VM_0_4_centos ~]# mysql -uroot -pkeIh:7roUido
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassWord@666'; Query OK, 0 rows affected (0.00 sec)
10.修改MySQL的密码策略:
[root@VM_0_4_centos ~]# vi /etc/my.cnf
validate_password_policy=2
[root@VM_0_4_centos ~]# systemctl restart mysqld
11.设置MySQL远程连接
[root@VM_0_4_centos ~]# mysql -uroot -pYourPassword
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YourPassword' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
12.设置MySQL默认的字符编码为UTF-8
character_set_server=utf8
init_connect='SET NAMES utf8'
13.CentOS下安装MySQL默认的配置文件位置
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)