Fedroa安装MySQL

安装MySQL

转换root权限

su -
## OR ##
sudo -i

安张yum仓库

## Fedora 28 ##
dnf install https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm

## Fedora 27 ##
dnf install https://dev.mysql.com/get/mysql80-community-release-fc27-1.noarch.rpm

## Fedora 26 ##
dnf install https://dev.mysql.com/get/mysql80-community-release-fc26-1.noarch.rpm

安装MySQL8

dnf install mysql-community-server

启动MySQL和默认开机启动MySQL

## 启动mysql
systemctl start mysqld.service
## 设置开机启动
systemctl enable mysqld.service

配置MySQL

生成随即root密码

grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1

终端输出结果例如:

2015-11-20T21:11:44.229891Z 1 [Note] A temporary password is generated for root@localhost: -et)QoL4MLid

随机密码为:-et)QoL4MLid

启动

在终端执行下面语句

/usr/bin/mysql_secure_installation

配置MySQL

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

使用MySQL

登录MySQL

建议使用mysql-workbench,mysql-workbench社区版下载地址:https://dev.mysql.com/downloads/workbench/

mysql -u root -p
## OR ##
mysql -h localhost -u root -p

mysql -u root -p
这时候会提示输入密码,记住了上面第1.3步安装时的密码,填入即可登录成功,进入MySQL命令模式。在MySQL8.0.4以前,执行

SET PASSWORD=PASSWORD('[修改的密码]');

就可以更改密码,但是MySQL8.0.4开始,这样默认是不行的。因为之前,MySQL的密码认证插件是“mysql_native_password”,而现在使用是“caching_sha2_password”。因为当前有很多数据库工具和链接包都不支持“caching_sha2_password”,为了方便,我暂时还是改回了“mysql_native_password”认证插件。
修改用户密码。修改密码验证插件,同时修改密码,在MySQL中执行命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

如果想默认使用“mysql_native_password”插件认证,可以在配置文件中配置default_authentication_plugin项。

[mysqld]
default_authentication_plugin=mysql_native_password

创建数据库、创建用户和允许远程连接

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL
## CREATE DATABASE ##
mysql> CREATE DATABASE webdb;

## CREATE USER ##
mysql> CREATE USER 'webdb_user'@'10.0.15.25' IDENTIFIED BY 'password123';

## GRANT PERMISSIONS ##
mysql> GRANT ALL ON webdb.* TO 'webdb_user'@'10.0.15.25';

##  FLUSH PRIVILEGES, Tell the server to reload the grant tables  ##
mysql> FLUSH PRIVILEGES;

原文地址:https://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/

你可能感兴趣的:(Fedroa,MySQL,Fedroa,mysql)