温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysql8.0二进制安装

发布时间:2020-03-04 00:56:47 来源:网络 阅读:295 作者:18620626259 栏目:MySQL数据库

mysql8.0二进制安装
1.创建目录授权
groupadd mysql
useradd mysql
mkdir -p /usr/local/mysql/
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql/etc
mkdir -p /usr/local/mysql/log
chown -R mysql:mysql /usr/local/mysql/


2.配置参数文件:
cat > /usr/local/mysql/etc/my.cnf << EOF
[client]
port                           = 3306
socket                         = /usr/local/mysql/data/mysql.sock
[mysqld]
server-id                      = 1
port                           = 3306
mysqlx_port                    = 33060
mysqlx_socket                  = /usr/local/mysql/data/mysqlx.sock
datadir                        = /usr/local/mysql/data
socket                         = /usr/local/mysql/data/mysql.sock
pid-file                       = /usr/local/mysql/data/mysqld.pid
log-error                      = error.log
slow-query-log                 = 1
slow-query-log-file            = slow.log
long_query_time                = 0.2
log-bin                        = bin.log
relay-log                      = relay.log
binlog_format                 =ROW
relay_log_recovery            = 1
character-set-client-handshake = FALSE
character-set-server           = utf8mb4
collation-server               = utf8mb4_unicode_ci
init_connect                   ='SET NAMES utf8mb4'
innodb_buffer_pool_size        = 1G
join_buffer_size               = 128M
sort_buffer_size               = 2M
read_rnd_buffer_size           = 2M
log_timestamps                 = SYSTEM
lower_case_table_names         = 1
default-authentication-plugin  =mysql_native_password
EOF

注意配置
[client]
socket                         = /usr/local/mysql/data/mysql.sock

[mysqld]
socket                         = /usr/local/mysql/data/mysql.sock


3.初始化数据库
/usr/local/mysql/bin/mysqld  --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
cat /usr/local/mysql/data/error.log | grep -i password



4.设置启动文件和环境变量:
cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql
systemctl start mysql


5、配置用户和密码
mysql> show variables like '%valid%pass%';
mysql> create user root@'%' identified by 'abc123';
mysql> show variables like '%valid%pass%';
mysql> alter user root@'localhost' identified by 'abc123';
mysql> show variables like '%valid%pass%';

--创建可以远程登录的用户:
mysql> create user root@'%' identified by 'abc123';
mysql> grant all privileges on *.* to root@'%' with grant option;
mysql> flush privileges;

# 创建账号密码
CREATE USER `root`@`127.0.0.1` IDENTIFIED BY 'shsnc\!\@\#';
CREATE USER `root`@`%` IDENTIFIED BY 'shsnc\!\@\#';

# 授予权限
GRANT ALL ON *.* TO `root`@`%` WITH GRANT OPTION;



# 删除权限
REVOKE all privileges ON databasename.tablename FROM 'username'@'host';

# 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';


mysql8修改密码
清空密码
UPDATE user SET Password = PASSWORD('shsnc!@#') WHERE user = 'root';
FLUSH privileges;

修改密码(注意不能直接改表)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "shsnc\!\@\#";
FLUSH privileges;




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI