赞
踩
vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
//安装
sudo apt-get install mysql-server mysql-client
//查看版本,出现下图即成功
mysql --version
n
执行以下命令:
sudo mysql_secure_installation
以下根据提示输入:
Enter current password for root (enter for none):<–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
//进入mysql
mysql -uroot -p -h localhost -P 3306
//创建用户,mysql8.0以上必须把创建和赋予权限分开,创建失败可能是你已经创建过了这个账号,使用下文命令查看mysql用户。
create user 'root'@'%' identified by '0';
//授权root用户的远程访问
grant all privileges on *.* to 'root'@'%' with grant option;
//创建普通用户
CREATE USER 'test'@'localhost' identified by 'test';
//授权普通用户本地访问权限
grant all privileges on *.* to 'test'@'localhost' with grant option;
//查看mysql用户
SELECT DISTINCT User FROM mysql.user;
个人经验总结,全部自己做了一遍,没有任何问题。因为在弄fisco-webase中间遇到了数据库安装的问题,所以自己整了一下。今天时间是2021.12.4.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。