MySQL 8 创建数据库和用户
-- 1. root 登录
-- mysql -u root -p
-- 2. 创建数据库
create database xm_db;
-- 3. 创建新用户(注意密码需满足安全策略)
create user 'xm_user'@'%' identified by '<密码>';
-- 4. 授权
grant all privileges on xm_db.* to xm_user@'%' with grant option;
-- 5. 刷新权限
flush privileges;
注意:从外部复制的单引号可能变成中文引号,执行时需改成英文单引号。
添加 MySQL 环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
原文链接:https://www.ssssmy.com/notes/mysql-8-chuang-jian-shu-ju-ku-he-yong-hu