匿名
未登录
登录
Linux78|wiki
搜索
查看“Centos 7 二进制安装Mysql 8”的源代码
来自Linux78|wiki
名字空间
页面
讨论
更多
更多
页面选项
查看
查看源代码
历史
←
Centos 7 二进制安装Mysql 8
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
wiki:用户|用户
您可以查看与复制此页面的源代码。
下载mysql二进制包,以及安装mysql依赖包 === 安装mysql8 二进制 === yum install libaio* -y wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz tar xf mysql-8.0.14-linux-glibc2.12-x86_64.tar.xz -C /usr/local ln -sv mysql-8.0.14-linux-glibc2.12-x86_64 mysql groupadd mysql useradd -r -g mysql -s /sbin/nologin mysql chown -R mysql.mysql /usr/local/mysql-8.0.18-linux-glibc2.12-x86_64/ chown -R mysql.mysql /usr/local/mysql mkdir -p /data/mysql/{data,log,binlog,tmp} chown -R mysql.mysql /data/mysql === 配置/etc/my.cnf文件=== vim /etc/my.cnf [mysqld] lower_case_table_names = 1 user = mysql server_id = 1 port = 3306 default-time-zone = '+08:00' enforce_gtid_consistency = ON gtid_mode = ON binlog_checksum = none default_authentication_plugin = mysql_native_password datadir = /data/mysql/data pid-file = /data/mysql/tmp/mysqld.pid socket = /data/mysql/tmp/mysqld.sock tmpdir = /data/mysql/tmp/ skip-name-resolve = ON open_files_limit = 65535 table_open_cache = 2000 innodb_data_home_dir = /data/mysql/data innodb_data_file_path = ibdata1:512M;ibdata2:512M:autoextend innodb_buffer_pool_size = 12000M innodb_flush_log_at_trx_commit = 1 innodb_io_capacity = 600 innodb_lock_wait_timeout = 120 innodb_log_buffer_size = 8M innodb_log_file_size = 200M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 85 innodb_read_io_threads = 8 innodb_write_io_threads = 8 innodb_thread_concurrency = 32 innodb_file_per_table innodb_rollback_on_timeout innodb_undo_directory = /data/mysql/data innodb_log_group_home_dir = /data/mysql/data join_buffer_size = 8M key_buffer_size = 256M bulk_insert_buffer_size = 8M max_heap_table_size = 96M tmp_table_size = 96M read_buffer_size = 8M sort_buffer_size = 2M max_allowed_packet = 64M read_rnd_buffer_size = 32M log-error = /data/mysql/log/mysqld.err log-bin = /data/mysql/binlog/binlog log_bin_index = /data/mysql/binlog/binlog.index max_binlog_size = 500M slow_query_log_file = /data/mysql/log/slow.log slow_query_log = 1 long_query_time = 10 log_queries_not_using_indexes = ON log_throttle_queries_not_using_indexes = 10 log_slow_admin_statements = ON log_output = FILE,TABLE master_info_file = /data/mysql/binlog/master.info === 初始化数据库 === /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/data/ === 制作启动文件 === cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #更改启动文件路径 vim /etc/init.d/mysqld #将basedir更改为basedir=/ointall/mysql #将datadir更改为datadir=/oradata/data #将mysqld_pid_file_path更改为mysqld_pid_file_path=/data/mysql/tmp #授予mysqld执行权限 chmod -R 755 /etc/init.d/mysqld #启动mysql服务 /etc/init.d/mysqld start #创建软连接 ln -vs /ointall/mysql/bin/mysql /usr/bin echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile === 修改密码 === 本地首次使用sock文件登录mysql是不需要密码的 mysql -S /data/mysql/tmp/mysqld.sock ............. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; mysql> flush privileges; mysql> select host,user from mysql.user; 退出, 此时密码重置后, 就不能使用sock文件无密码登录了 mysql -S /data/mysql/tmp/mysqld.sock ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) mysql -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 做sock文件的软链接 ln -s /data/mysql/tmp/mysqld.sock /tmp/mysql.sock mysql -p123456 ............. mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.18 | +-----------+ ===建立mysql systemd服务脚本=== vim /usr/lib/systemd/system/mysqls.service [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 #Restart=on-failure #RestartPreventExitStatus=1 #PrivateTmp=false [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 #Restart=on-failure #RestartPreventExitStatus=1 #PrivateTmp=false 重新加载文件 systemctl daemon-reload 启动、状态、停止 systemctl start mysqld === 授予用户权限 === 授予用户权限. 必须先要创建用户, 才能授权!! (创建用户时要带@并指定地址, 则grant授权时的地址就是这个@后面指定的!, 否则grant授权就会报错!) mysql> create user 'zhangsan'@'%' identified by '123456'; mysql> grant all privileges on *.* to 'zhangsan'@'%' with grant option; mysql> select user,host from mysql.user; +------------------+-----------+ | user | host | +------------------+-----------+ | zhangsan | % | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ mysql> update mysql.user set host='192.168.%.%' where user='zhangsan'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user; +------------------+-------------+ | user | host | +------------------+-------------+ | zhangsan | 192.168.%.% | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-------------+ ===参考=== https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html MySQL启动之后监听了两个端口3306和33060。 这是应为MySQL5.7.12 之后新增了X plugin。这个插件默认是启用的,可以在配置配置文件/etc/my.cnf 添加mysqlx=0关闭X plugin。 也可以在启动时指定 --mysqlx=0 或 --skip-mysqlx 来禁用X插件。 libaio项目: http://oss.oracle.com/projects/libaio-oracle/ This is a library for accessing the new AIO system calls (asynchronous i/o) for the Linux kernel. It is a thin, state-keeping wrapper that conforms to the Single Unix Specification for aio_read, aio_write, aio_error, aio_return and aio_suspend functions, and also implements lio_listio and aio_reap for batch processing. This library requires a kernel with the new AIO code and a recent version of the libaio userspace library.
返回至
Centos 7 二进制安装Mysql 8
。
导航
导航
首页
最近更改
随机页面
栏目
Nginx
Kubernetes
Spring Cloud
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志