linux下安装mysql

@linux下安装mysql

0、导入jar包到opt/mysql

1、检查

rpm -qa|grep mariadb
如果存在则卸载
请先执行卸载命令:rpm -e – nodeps mariadb-libs-5.5.56-2.e17.x86_64
必须有如下两个包
rpm -qa|grep libaio
rpm -qa|grep net-tools

2、授权 chmod -R 777 /tmp

3、安装mysql

rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-server-5.7.16-1.el7.x86_64.rpm
另一种:yum安装

4、查看版本

mysqladmin --version命令

5、初始化服务

mysqld --initialize --user=mysql

6、查看密码

cat /var/log/mysqld.log

7、相关服务

启动 systemctl start mysqld.service
关闭 systemctl stop mysqld.service

8、登录修改密码

mysql -u root -p
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;

9、修改字符集

vim /etc/my.cnf
在最后加上:character_set_server=utf8
并重启
systemctl restart mysqld.service

skip-name-resolve 表示跳过dns解析以后连接mysql
linux下安装mysql_第1张图片

10、授权远程连接

再次登录mysql授予远程连接
grant all privileges on . to root@‘%’ identified by ‘123456’;
刷新权限
flush privileges;
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl restart mysqld.service

最后本地连接

你可能感兴趣的:(运维,linux,mysql,服务器)