RHEL 7.3 安装 MySQL 5.6 教程(2)

Filling help tables...2016-12-12 13:24:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-12-12 13:24:20 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2016-12-12 13:24:20 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.34) starting as process 4098 ...
2016-12-12 13:24:20 4098 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-12-12 13:24:20 4098 [Note] InnoDB: The InnoDB memory heap is disabled
2016-12-12 13:24:20 4098 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-12-12 13:24:20 4098 [Note] InnoDB: Memory barrier is not used
2016-12-12 13:24:20 4098 [Note] InnoDB: Compressed tables use zlib 1.2.7
2016-12-12 13:24:20 4098 [Note] InnoDB: Using CPU crc32 instructions
2016-12-12 13:24:20 4098 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-12-12 13:24:20 4098 [Note] InnoDB: Completed initialization of buffer pool
2016-12-12 13:24:20 4098 [Note] InnoDB: Highest supported file format is Barracuda.
2016-12-12 13:24:20 4098 [Note] InnoDB: 128 rollback segment(s) are active.
2016-12-12 13:24:20 4098 [Note] InnoDB: Waiting for purge to start
2016-12-12 13:24:20 4098 [Note] InnoDB: 5.6.34 started; log sequence number 1625977
2016-12-12 13:24:20 4098 [Note] RSA private key file not found: /mydata/data//private_key.pem. Some authentication plugins will not work.
2016-12-12 13:24:20 4098 [Note] RSA public key file not found: /mydata/data//public_key.pem. Some authentication plugins will not work.
2016-12-12 13:24:20 4098 [Note] Binlog end
2016-12-12 13:24:20 4098 [Note] InnoDB: FTS optimize thread exiting.
2016-12-12 13:24:20 4098 [Note] InnoDB: Starting shutdown...
2016-12-12 13:24:21 4098 [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:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h test password 'new-password'

Alternatively you can run:

/usr/local/mysql/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 . ; /usr/local/mysql/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

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses at

New default config file was created as /usr/local/mysql/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

-------------------------------------------------------------------------------------------------------------------------

可能出现的错误:

bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory

安装 perl 后问题解决

-------------------------------------------------------------------------------------------------------------------------

 4、配置文件

# cp support-files/my-default.cnf /etc/my.cnf

5、添加到服务

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

# chkconfig --add mysqld

# chkconfig mysqld on

6、添加到环境变量

# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

添加到 /etc/profile 后,为什么没有生效呢?

别忘了执行下一步:

# source /etc/profile

7、启动

# service mysqld start

8、测试

# mysql -uroot -p

初始没有密码,直接回车

登录成功

RHEL 7.3 安装 MySQL 5.6 教程

测试

RHEL 7.3 安装 MySQL 5.6 教程

9、设置密码

方式一:

# mysqladmin -uroot password 要设置的密码(加不加引号都可以)

或者
# mysqladmin -u用户名 -p旧密码 password 新密码(加不加引号都可以)

方式二:

mysql> SET PASSWORD FOR '用户名'@'主机' = PASSWORD('密码');

方式三:

mysql> update mysql.user set password=PASSWORD('要设置的密码') where user='root';

mysql> flush privileges; # 刷新数据库权限

10、创建用户

1)创建用户

mysql> create user '用户名'@'%' identified by '密码';

2)创建用户并授权

mysql> grant all privileges on *.* to 用户名@'%' identified by '密码' with grant option;

mysql> flush privileges;# 刷新数据库权限

五、常用命令

启动:service mysqld start

停止:service mysqld stop

重启:service mysqld restart

重载配置:service mysqld reload

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/20bfee84036e053a384d76e3a262536f.html