Linux创建Mysql库

1,先下载资源:

  链接:https://pan.baidu.com/s/1SKlmCcrr9vA9oTnoHVMX4w 提取码:hkdj

1.1,把安装包安装mysql源:

yum -y localinstall mysql80-community-release-el7-3.noarch.rpm

1.2,安装服务,下载的东西比较多要稍微等会:

yum -y install mysql-community-server

1.3,启动mysql:

systemctl start mysqld

1.4,设置开机启动:

systemctl enable mysqld
systemctl daemon-reload

1.5,通过cat /var/log/mysqld.log | grep password命令查看数据库的密码:

1.6,通过mysql -uroot -p进入数据库登陆界面,输入刚刚查到的密码,进行数据库的登陆,复制粘贴就行,MySQL 的登陆密码也是不显示的:

1.7, 通过ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';命令来修改密码:

通过 exit; 命令退出 MySQL,然后通过新密码(root)再次登陆

如有提示报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
输入以下命令:

set global validate_password.policy=0;
set global validate_password.length=1;

2,通过以下命令,进行远程访问的授权:

create user 'root'@'%' identified with mysql_native_password by '你的密码';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

2.1,输入exit退出,打开防火墙开放3306端口:

如果没有开启防火墙,则输入:systemctl start firewalld 开启

输入下面命令,开放3306端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

2.2,配置默认编码为UTF-8:

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:

character_set_server=utf8
init_connect='SET NAMES utf8'

2.3,编辑保存完重启mysql服务: systemctl restart mysqld:

2.4,查看下编码:mysql> show variables like '%character%';

2.5,最后,使用工具即可链接成功:


溜啦溜啦...

posted @ 2020-07-30 18:20  姜煜  阅读(730)  评论(0编辑  收藏  举报