MySQL-8.0安装

1下载
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
2解压mysql
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
3 重命名文件夹
 mv  mysql-8.0.11-linux-glibc2.12-x86_64 mysql-8.0.11
4创建data文件夹 存储文件
[root@localhost mysql]# cd mysql-8.0.11
[root@localhost mysql-8.0.11]# mkdir data
5创建用户组以及用户和密码

[root@localhost mysql-8.0.11]# groupadd mysql
[root@localhost mysql-8.0.11]# useradd -g mysql mysql

6授权用户

[root@localhost mysql-8.0.11]# chown -R mysql.mysql /home/mysql/mysql-8.0.11

7切换到bin目录下

[root@localhost mysql-8.0.11]# cd bin

8 初始化基础信息

 ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --initialize

得到临时密码  记的保存
 A temporary password is generated for root@localhost: xZnuY,)Rv1oK
xZnuY,)Rv1oK
,
9 编辑my.cnf文件
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
character-set-server=utf8
lower-case-table-names=0
default_authentication_plugin=mysql_native_password
innodb_deadlock_detect = off
innodb_lock_wait_timeout = 120
innodb_rollback_on_timeout = on
innodb_flush_log_at_trx_commit = 2
innodb_log_file_size = 512M
innodb_buffer_pool_size = 1073741824
innodb_log_buffer_size = 134217728

max_connections=500

max_user_connections=500

wait_timeout=200

[client]
port = 3306

10 添加mysqld服务到系统
cp -a ./support-files/mysql.server /etc/init.d/mysql

11授权以及添加服务

[root@localhost mysql]# chmod +x /etc/init.d/mysql
[root@localhost mysql]# chkconfig --add mysql

12.启动mysql

[root@localhost mysql]# service mysql start
Starting MySQL..... SUCCESS! 
常见错误
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL.my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
.... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
编辑my.cnf文件 参考 编辑my.cnf文件


13.查看启动状态

[root@localhost mysql]# service mysql status
SUCCESS! MySQL running (62693)

14.将mysql命令添加到服务

[root@localhost mysql]# ln -s /usr/local/mysql/bin(安装包路径) /usr/local/bin
ln -s /usr/local/mysql/bin/mysql  /usr/local/bin
15.登录mysql mysql -uroot -p 密码使用之前随机生成的密码

[root@localhost mysql-8.0.11]# mysql -uroot -p
报错:-bash: mysql: command not found
注意:ln -s /usr/local/mysql/bin/mysql(安装包路径bin/mysql)  /usr/local/bin

16.修改root密码其中123456是新的密码自己设置

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

17.执行 使密码生效

mysql> flush privileges;

18.选择mysql数据库

mysql> use mysql;

19.修改远程连接并生效

mysql> update user set host='%' where user='root';

mysql> flush privileges;
 

你可能感兴趣的:(mysql,java,数据库,javascript)