mysql 安装

安装mysql

centos7 安装mysql

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

centos8 安装mysql

yum install mysql-server

安装之后重启mysql服务

service mysqld restart

初次安装mysql是root账户是没有密码的
设置密码的方法

mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit

查询mysql 初始密码

su grep 'temporary password' /var/log/mysqld.log

重置mysql 密码

停止mysql 服务

/etc/init.d/mysqld stop
/etc/init.d/mysql stop

输入绕过密码认证命令

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

登录后修改密码即可

创建用户

create user 'onewuqi'@'%' identified with mysql_native_password by 'onewuqi@123456';

create user 'onewuqi'@'%' identified  by 'onewuqi@123456';

创建了用户名为onewuqi,密码为onewuqi@123456的用户,如果需要用navicat连接,则使用老的加密方式mysql_native_password,如果是8.0以前的数据库,可以不加。

授权远程登录

grant all on *.* to 'imooc'@'%';
flush privileges;

发表回复