本文主要给大家简单讲讲linux7.2系统下实现二进制安装MySQL8.0.11方法,相关专业术语大家可以上网查查或者找一些相关书籍补充一下,这里就不涉猎了,我们就直奔主题吧,希望linux7.2系统下实现二进制安装MySQL8.0.11方法这篇文章可以给大家带来一些实际帮助。
为日照等地区用户提供了全套网页设计制作服务,及日照网站建设行业解决方案。主营业务为网站设计、成都做网站、日照网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!1、下载二进制软件包:
mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
2、添加MySQL用户和组:
[root@localhost ~]# userdel mysql (因为是新系统,所以就把现有的MySQL用户给删除了) [root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql [root@localhost ~]# passwd mysql (MySQL密码要设置的复杂一点,或者在创建用户的时候设置不让登陆系统)
3、创建安装MySQL目标,并解压软件到指定目录
[root@localhost ~]# mkdir -p /mysql/data [root@localhost ~]# chown -R mysql.mysql /mysql [root@localhost ~]# tar zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /mysql [root@localhost ~]# cd /mysql [root@localhost ~]# mv mysql-8.0.11-linux-glibc2.12-x86_64 / mysql [root@localhost ~]# chown -R mysql.mysql /mysql
4、初始化数据库
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ vim /mysql/my.cnf
[client] socket=/mysql/data/mysql.sock [mysqld] server-id=142 port = 3306 basedir=/mysql/mysql datadir=/mysql/data socket=/mysql/data/mysql.sock log-error=/mysql/data/mysqld.log pid-file=/mysql/data/mysqld.pid log-bin=/mysql/data/binlog slow_query_log_file = /mysql/data/slow.log log_slave_updates expire_logs_days=7 binlog_format=ROW #default_authentication_plugin=mysql_native_password ---修改密码加密方式。(看文中最后的解释) gtid-mode = on enforce-gtid-consistency = 1 skip_slave_start=1 innodb_buffer_pool_size = 1000M innodb_buffer_pool_instances = 2 innodb_log_file_size = 100M innodb_log_files_in_group = 3 innodb_log_buffer_size = 24M innodb_flush_log_at_trx_commit = 1 innodb_file_per_table = 1 innodb_flush_method = O_DIRECT innodb_io_capacity = 200 innodb_io_capacity_max = 600 innodb_thread_concurrency = 0 innodb_autoinc_lock_mode = 2 innodb_lock_wait_timeout = 60 innodb_read_io_threads = 4 innodb_write_io_threads = 4 innodb_max_dirty_pages_pct = 80 innodb_autoextend_increment = 512 innodb_checksum_algorithm = NONE max_connect_errors = 1000 max_connections = 500 connect_timeout = 300 wait_timeout = 86400 interactive_timeout = 86400
[mysql@localhost mysql]$ /mysql/mysql/bin/mysqld --defaults-file=/mysql/my.cnf --user=mysql --basedir=/mysql/mysql/ --datadir=/mysql/data/ --initialize
其中,root的默认密码在:/mysql/data/mysqld.log 日志中,打开查看即可
5、启动MySQL
[root@localhost mysql]# /mysql/mysql/bin/mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql & [root@localhost mysql]# /mysql/mysql/bin/mysql -uroot -p -S /mysql/data/mysql.sock mysql> set password='123456'; mysql> flush privileges; mysql> \s -------------- /mysql/mysql/bin/mysql Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL) Connection id: 11 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.11 MySQL Community Server - GPL Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /mysql/data/mysql.sock Uptime: 10 min 31 sec Threads: 2 Questions: 10 Slow queries: 0 Opens: 124 Flush tables: 2 Open tables: 100 Queries per second avg: 0.015 --------------
(注意:这里启动数据库一定要用MySQL8.0安装包自带的客户端才可以登录,即要使用MySQL8.0安装包的命令进行登录数据库,要不然会报错,如:
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded:)
注意:
在mysql8.0下,默认变成了default_authentication_plugin=caching_sha2_password,包括你刚初始化的root用户也是这个认证加密方式,这样的结果是让你除非用新的协议驱动,例如必须用8.0自带的mysql客户端才行,不然就连接不上数据库.
在mysql5.7环境里,虽然可以设置default_authentication_plugin来改变认证加密方式,但是一般人不会去设置.所以默认使用的认证加密方式是mysql_native_password
解决方法:
①:在初始化的时候在配置文件中加入,如下,mysql_native_password 这种认证方法就会很多客户端的认证加密方式一样。
vim my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
②:使用命令行模式更改用户的密码加密认证方式:
mysql> select Host,User,plugin,authentication_string from mysql.user; --看下面的root用户的认证方式和其他用户都是不一样的, +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | Host | User | plugin | authentication_string | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | root | caching_sha2_password | $A$005$T?yK{e`l{mrnZd|0iETvMwJ197qvnDXttfzdZX98q6xvFBwXuWd3ioPfnV7 | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ 4 rows in set (0.00 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; ---在修改密码的时候指定密码加密认证方式 Query OK, 0 rows affected (0.11 sec) mysql> select Host,User,plugin,authentication_string from mysql.user; ---再次查看所有用户都一样了,和5.7版本一样 +-----------+------------------+-----------------------+-------------------------------------------+ | Host | User | plugin | authentication_string | +-----------+------------------+-----------------------+-------------------------------------------+ | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | +-----------+------------------+-----------------------+-------------------------------------------+ 4 rows in set (0.00 sec)
另外,在MySQL8.0授权和创建用户更加严格了,在MySQL5.7可以使用命令如下:
MySQL [(none)]> grant all privileges on *.* to 'test_user'@'192.168.2.%' identified by '123123'; ----MySQL5.7创建用户授权的方法,报错了,
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123123'' at line 1
在MySQL8.0中必须先创建用户再授权:
MySQL > create user 'test_user'@'%' identified by '123456'; --先创建用户
Query OK, 0 rows affected (0.03 sec)
MySQL > grant all privileges on *.* to 'test_user'@'%' with grant option; --再授权
Query OK, 0 rows affected (0.05 sec)
linux7.2系统下实现二进制安装MySQL8.0.11方法就先给大家讲到这里,对于其它相关问题大家想要了解的可以持续关注我们的行业资讯。我们的板块内容每天都会捕捉一些行业新闻及专业知识分享给大家的。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
新闻标题:linux7.2系统下实现二进制安装MySQL8.0.11方法-创新互联
文章源于:http://lswzjz.com/article/copede.html