mysql安装
下载
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
解压
tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
移动命名
mv ./mysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
创建data文件
cd /usr/local/mysql/
mkdir ./data
创建用户和用户组
# 用户组
groupadd mysql
# 用户 (用户名/密码)
useradd -g mysql mysql
授权
chown -R mysql.mysql /usr/local/mysql/
初始化数据库
进入到mysqld
./bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --initialize
#yum install -y libaio
Mysql配置
vi /etc/my.cnf
配置如下内容
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server = utf8
port = 3306
default_authentication_plugin = mysql_native_password
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set = utf8
# 添加Mysql到系统服务
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
# 检查服务是否生效
chkconfig --list mysql
启动Mysql服务
service mysql start;
启动报错需要如下操作
[root@localhost ~]# mkdir /var/log/mariadb
[root@localhost ~]# touch /var/log/mariadb/mariadb.log
[root@localhost ~]# chown -R mysql:mysql /var/log/mariadb/
登录
mysql -uroot -p
报错操作如下执行命令:
ln -s /usr/local/mysql/bin/mysql /usr/bin
修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
进入mysql数据库添加远程登录账号
use mysql
update user set host ='%' where user='root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
FLUSH PRIVILEGES;