centos7.5 环境安装mysql5.6

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

安装mysql环境

[root@localhost mysql]#copy file to /usr/local/
[root@localhost mysql]#tar -xvf mysq.tar.gz
[root@localhost mysql]#ln -s mysql.5.6 mysql

[root@localhost mysql]#rpm -qa | grep libaio

添加组,用户

[root@localhost mysql]#groupadd mysql

[root@localhost mysql]#useradd -r -g mysql -s /bin/false mysql

[root@localhost mysql]#chown -R mysql:mysql /usr/local/mysql-5.6.42-linux-glibc2.12-x86_64

[root@localhost mysql]#ln -s mysql-5.6.42-linux-glibc2.12-x86_64 mysql

[root@localhost mysql]# pwd

/usr/local/mysql

[root@localhost mysql]# yum -y install autoconf

安装 mysql服务

[root@localhost mysql]# scripts/mysql_install_db –user=mysql

Installing MySQL system tables…2019-10-26 22:40:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-26 22:40:46 0 [Note] Ignoring –secure-file-priv value as server is running with –bootstrap.
2019-10-26 22:40:46 0 [Note] ./bin/mysqld (mysqld 5.6.42) starting as process 36184 …
2019-10-26 22:40:46 36184 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-10-26 22:40:46 36184 [Note] InnoDB: The InnoDB memory heap is disabled
2019-10-26 22:40:46 36184 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-26 22:40:46 36184 [Note] InnoDB: Memory barrier is not used
2019-10-26 22:40:46 36184 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-26 22:40:46 36184 [Note] InnoDB: Using Linux native AIO
2019-10-26 22:40:46 36184 [Note] InnoDB: Using CPU crc32 instructions
2019-10-26 22:40:46 36184 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-10-26 22:40:46 36184 [Note] InnoDB: Completed initialization of buffer pool
2019-10-26 22:40:46 36184 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2019-10-26 22:40:46 36184 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2019-10-26 22:40:46 36184 [Note] InnoDB: Database physically writes the file full: wait…
2019-10-26 22:40:46 36184 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2019-10-26 22:40:46 36184 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2019-10-26 22:40:46 36184 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-10-26 22:40:46 36184 [Warning] InnoDB: New log files created, LSN=45781
2019-10-26 22:40:46 36184 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-10-26 22:40:46 36184 [Note] InnoDB: Doublewrite buffer created
2019-10-26 22:40:46 36184 [Note] InnoDB: 128 rollback segment(s) are active.
2019-10-26 22:40:46 36184 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-10-26 22:40:46 36184 [Note] InnoDB: Foreign key constraint system tables created
2019-10-26 22:40:46 36184 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-10-26 22:40:46 36184 [Note] InnoDB: Tablespace and datafile system tables created.
2019-10-26 22:40:46 36184 [Note] InnoDB: Waiting for purge to start
2019-10-26 22:40:46 36184 [Note] InnoDB: 5.6.42 started; log sequence number 0
2019-10-26 22:40:46 36184 [Note] Binlog end
2019-10-26 22:40:46 36184 [Note] InnoDB: FTS optimize thread exiting.
2019-10-26 22:40:46 36184 [Note] InnoDB: Starting shutdown…
2019-10-26 22:40:48 36184 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables…2019-10-26 22:40:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-26 22:40:48 0 [Note] Ignoring –secure-file-priv value as server is running with –bootstrap.
2019-10-26 22:40:48 0 [Note] ./bin/mysqld (mysqld 5.6.42) starting as process 36206 …
2019-10-26 22:40:48 36206 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-10-26 22:40:48 36206 [Note] InnoDB: The InnoDB memory heap is disabled
2019-10-26 22:40:48 36206 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-26 22:40:48 36206 [Note] InnoDB: Memory barrier is not used
2019-10-26 22:40:48 36206 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-26 22:40:48 36206 [Note] InnoDB: Using Linux native AIO
2019-10-26 22:40:48 36206 [Note] InnoDB: Using CPU crc32 instructions
2019-10-26 22:40:48 36206 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-10-26 22:40:48 36206 [Note] InnoDB: Completed initialization of buffer pool
2019-10-26 22:40:48 36206 [Note] InnoDB: Highest supported file format is Barracuda.
2019-10-26 22:40:48 36206 [Note] InnoDB: 128 rollback segment(s) are active.
2019-10-26 22:40:48 36206 [Note] InnoDB: Waiting for purge to start
2019-10-26 22:40:48 36206 [Note] InnoDB: 5.6.42 started; log sequence number 1625977
2019-10-26 22:40:48 36206 [Note] Binlog end
2019-10-26 22:40:48 36206 [Note] InnoDB: FTS optimize thread exiting.
2019-10-26 22:40:48 36206 [Note] InnoDB: Starting shutdown…
2019-10-26 22:40:50 36206 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password ‘new-password’
./bin/mysqladmin -u root -h localhost.localdomain password ‘new-password’

Alternatively you can run:

./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
–defaults-file argument to mysqld_safe when starting the server

复制mysql.server至启动目录

[root@localhost mysql]#cp support-files/mysql.server /etc/init.d/mysql.server

[root@localhost mysql]# chown -R mysql:mysql /var/log/

[root@localhost mysql]# mkdir -p /var/log/mariadb
[root@localhost mysql]# touch /var/log/mariadb/mariadb.log

以安全模式启动mysql并修改mysql密码

[root@localhost mysql]#bin/mysqld_safe –user=mysql &
[root@localhost mysql]#./bin/mysqladmin -u root password ‘123456’

配置mysql允许远程访问

[root@localhost mysql]#sql>mysql -uroot -p
[root@localhost mysql]#sql> use mysql;
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
flush privileges;

regist service

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

停止安全模式下的mysql的进程命令

[root@localhost mysql]#mysqladmin -uroot -p shutdown

start with shell:
配置开机启动

[root@localhost mysql]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql]#chkconfig –list mysqld
[root@localhost mysql]#chkconfig –add mysqld
[root@localhost mysql]#chkconfig mysqld on

注意防火墙是否开启

[root@localhost bin]# systemctl status firewalld
[root@localhost bin]# systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@localhost bin]# systemctl stop firewalld
[root@localhost bin]# systemctl status firewalld

配置mysql全局的编码方式

[mysql]
default-character-set=utf8

[mysqld]
character_set_server=utf8
分类: mysql

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据