Linux安装MySQL8.0.11
1.1 官网手动下载:
官网网址:https://dev.mysql.com/downloads/mysql/
1.2.上传到目录/opt下
解压
tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
cd mysql-8.0.11-linux-glibc2.12-x86_64/
mkdir data
2.2 创建用户及用户组
groupadd mysql
useradd -g mysql mysql
2.3 授权
chown -R mysql.mysql /opt/mysql-8.0.11-linux-glibc2.12-x86_64/
2.4 初始化数据库
./bin/mysqld --user=mysql --basedir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64/ --datadir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64/data/ --initialize
生成以下日志,则初始化成功:
[root@cluster-master mysql-8.0.11-linux-glibc2.12-x86_64]# ./bin/mysqld --user=mysql --basedir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64/ --datadir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64/data/ --initialize
2020-10-13T08:54:31.782839Z 0 [System] [MY-013169] [Server] /opt/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 2282
2020-10-13T08:54:35.877719Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: oa0a7rNVuq(:
2020-10-13T08:54:39.205509Z 0 [System] [MY-013170] [Server] /opt/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server has completed
日志中的 oa0a7rNVuq(: 为root的临时密码
2.5 Mysql配置
vi /etc/my.cnf,添加以下内容
[mysqld]
default_authentication_plugin=mysql_native_password
basedir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64
datadir=/opt/mysql-8.0.11-linux-glibc2.12-x86_64/data
socket=/tmp/mysql.sock
character-set-server=utf8
# skip-grant-tables
2.6 建立MySQL服务
cp -a /opt/mysql-8.0.11-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig --list mysql
3、启动Mysql服务
service mysql start
service mysql status
配置引用
ln -s /opt/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysql /usr/bin
登陆Mysql:
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
4、远程连接
1.在 my.cnf 的mysqld 下增加
default_authentication_plugin=mysql_native_password
2.进入mysql命令行
-
use mysql
-
update user set host ='%' where user='root';
-
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
-
FLUSH PRIVILEGES;使用客户端工具进行连接。<!-- 数据库集成配置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://nns:3306/hivedb?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=UTC</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>