CentOS安装Mysql8并设置开机自启动【我】

 

先安装JDK:

我使用:

export JAVA_HOME=/myapp/jdk/jdk1.8.0_291
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 

 

 

安装mysql

参考:

 

Centos7安装mysql8.0教程

 

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

sudo yum --enablerepo=mysql80-community install mysql-community-server

sudo service mysqld start

【上面过程中一路y】

 

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘新密码‘;

 

 

在Linux上安装MySQL

 

解决mysql8 提示 ERROR 1410 (42000): You are not allowed to create a user with GRANT

# 使用mysql 数据库
mysql > use mysql;
# 特定用户的host 修改
mysql > update user set host=‘%‘ where user=‘root‘;
# 指定用户的授权
mysql > grant all privileges on test.* to root@‘%‘

flush privileges;

 

 

 

转:

CentOS 8安装Mysql8并设置开机自启动

1, 看起来mysql又提供yum安装了。
yum install mysql-server
先安装wget
yum -y install wget

2,下载rpm安装文件
wget http://repo.mysql.com/mysql-community-release-el7.rpm

3,执行rpm安装
rpm -ivh mysql-community-release-el7.rpm
依赖解析完成后,出现下列选项:

 1 Dependencies Resolved
 2 
 3 ================================================================================================================================================================
 4  Package                                                  Arch                 Version                  Repository                          Size
 5 ================================================================================================================================================================
 6 Installing:
 7  mysql-community-libs                                    x86_64              5.6.32-2.el7             mysql56-community                    2.0 M
 8  replacing  mariadb-libs.x86_64 1:5.5.47-1.el7_2
 9  mysql-community-server                                  x86_64              5.6.32-2.el7             mysql56-community                     59 M
 10  Installing for dependencies:
 11  mysql-community-client                                  x86_64              5.6.32-2.el7             mysql56-community                     19 M
 12  mysql-community-common                                  x86_64              5.6.32-2.el7             mysql56-community                    256 k
 13  perl-Compress-Raw-Bzip2                                 x86_64              2.061-3.el7              base                                  32 k
 14  perl-Compress-Raw-Zlib                                  x86_64              1:2.061-4.el7            base                                  57 k
 15  perl-DBI                                                x86_64              1.627-4.el7              base                                 802 k
 16  perl-IO-Compress                                        noarch              2.061-2.el7              base                                 260 k
 17  perl-Net-Daemon                                         noarch              0.48-5.el7               base                                  51 k
 18  perl-PlRPC                                              noarch              0.2020-14.el7            base                                  36 k
 19 
 20 Transaction Summary
 21 ================================================================================================================================================================
 22 Install  2 Packages (+8 Dependent packages)
 23 
 24 Total download size: 82 M
 25 Is this ok [y/d/N]: 

4,可以看出,server和client都被选择安装。选择y,自动下载安装。

5,安装完成后,启动Mysql。
systemctl start mysqld.service

启动

1、使用 service 启动:service mysqld start

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

停止

1、使用 service 启动:service mysqld stop

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop

重启

1、使用 service 启动:service mysqld restart

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart

登录mysql:mysql -u root -p(开始密码默认为空,直接回车)

6,设置密码
use mysql
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘密码‘;

/update user set password=password("123456") where user=‘root‘;/

7,开机自启动
systemctl enable mysqld
systemctl daemon-reload

8,重要更新
新的rpm安装文件没有自动yum安装的脚本了,需要手动执行yum安装。

即步骤3之后执行yum install mysql-server即可。

9,关于自启动

步骤7只适用于mysqld没有自启动的条件下。

如果默认mysql是自启动的,可能和rc.local中的自启动出现乱序之类的问题。

更稳妥的一个解决办法见:

CentOS 7 程序自启动的问题

http://www.cnblogs.com/yoyotl/p/6194321.html

打开远程访问:

修改host为所有ip可登陆
update user set host=‘%‘ where user=‘root‘;
修改密码
Alter user ‘root‘@‘%‘ identified by ‘密码‘;
授权
grant all privileges on *.* to ‘root‘@‘%‘ with grant option;
FLUSH PRIVILEGES;
详解查看:https://www.cnblogs.com/stronger-xsw/p/12785801.html

1:linux登录mysql

[root@localhost mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> 

2:查看user表,修改连接级别

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)

原文链接:https://blog.csdn.net/gdsgdh308227363/article/details/103308801

export JAVA_HOME=/myapp/jdk/jdk1.8.0_291
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

CentOS安装Mysql8并设置开机自启动【我】

上一篇:在windows 10 bash里编写脚本


下一篇:pgsql学习