安装步骤
安装前,我们可以检测系统是否自带安装 MySQL:
rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql
安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server
初始化 MySQL:
mysqld --initialize
启动 MySQL:
systemctl start mysqld
查看 MySQL 运行状态:
systemctl status mysqld
centos启动mysql报错
$ systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-pre) since 一 2018-09-03 06:27:17 EDT; 631ms ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 26472 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Control: 26489 (mysqld_pre_syst)
Memory: 26.6M
CGroup: /system.slice/mysqld.service
└─control
├─26489 /bin/bash /usr/bin/mysqld_pre_systemd
└─26506 /usr/bin/python -Es /usr/sbin/semanage fcontext -a -e /var/lib/mysql /var/lib/mysql-files
9月 03 06:27:17 test241vm22 systemd[1]: Starting MySQL Server...
解决办法
chown mysql:mysql -R /var/lib/mysql
修改初始密码
You must reset your password using ALTER USER statement before executing this statement.
安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个
step 1: SET PASSWORD = PASSWORD(‘your new password‘);
step 2: ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
step 3: flush privileges;
创建用户,授权远程登陆
create user ‘test‘@‘10.1.3.200‘ identified by ‘123456‘;
grant all privileges on *.* to ‘sl_test‘@‘10.100.0.0‘;
flush privileges;
导入数据库
source /data/model/tables.sql
原文地址:http://blog.51cto.com/12880687/2169839
时间: 2024-10-06 08:42:43