博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos 6.x 安装配置MySQL
阅读量:2388 次
发布时间:2019-05-10

本文共 7144 字,大约阅读时间需要 23 分钟。

1、安装

[root@server ~]# yum install mysql-server
================================================================================================================================================= Package                               Arch                          Version                                Repository                      Size=================================================================================================================================================Installing: mysql-server                          x86_64                        5.1.73-7.el6                           rhel6.8                        8.6 MInstalling for dependencies: mysql                                 x86_64                        5.1.73-7.el6                           rhel6.8                        894 k perl-DBD-MySQL                        x86_64                        4.013-3.el6                            rhel6.8                        134 kTransaction Summary=================================================================================================================================================Install       3 Package(s)Total download size: 9.6 MInstalled size: 27 MIs this ok [y/N]: y

2、启动

service mysqld start

chkconfig mysqld on

[root@server ~]# service mysqld startInitializing MySQL database:  Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h server password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!                                                           [  OK  ]Starting mysqld:                                           [  OK  ][root@server ~]# chkconfig mysqld on

3、一般配置

[root@server ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the currentpassword for the root user.  If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n ... skipping.By default, MySQL comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] n ... skipping.Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL![root@server ~]#

4、远程登录授权

[root@server ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 9Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql>
[root@node1 ~]# mysql -h10.17.12.15 -uroot -p123456Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 10Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

5、编码设置

[root@server ~]# vi /etc/my.cnf[root@server ~]# cat /etc/my.cnf[mysqld]character-set-server=utf8datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid[client]default-character-set=utf8[mysql]default-character-set=utf8[root@BigData01-TEST ~]#

重启

[root@server ~]# service mysqld restartStopping mysqld:                                           [  OK  ]Starting mysqld:                                           [  OK  ][root@server ~]# mysql -uroot -p123456Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show variables like "%character%";+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | utf8                       || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | utf8                       || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)mysql>

转载地址:http://rqvab.baihongyu.com/

你可能感兴趣的文章
zz-LDAP详解
查看>>
zZ-google-perftools 加速MySQL – TCMalloc
查看>>
apache 防DDOS脚本
查看>>
使用syslog-ng 和stunnel 创建集中式安全日志服务器
查看>>
网友将电视剧潜伏当职场教科书 研究办公室政治
查看>>
graudit
查看>>
使用Hudson和FindBugs进行持续集成和代码检查
查看>>
New Tool: The PenTesters Framework (PTF) Released
查看>>
Detecting and Defending against PowerShell Shells
查看>>
NagVis实物监控工具
查看>>
nginx - low risk webdav destination bug
查看>>
Lessons Learned from Building and Running MHN, the World's Largest Crowdsourced Honeynet
查看>>
Logwatch Linux/Unix系统日志检测软件
查看>>
减少Linux下Squid服务器的TIME_WAIT套接字数量
查看>>
/etc/sudoers中的含义
查看>>
Five must-know open source SDN controllers
查看>>
Finding Bad Guys with 35 million Flows, 2 Analysts, 5 Minutes and 0 Dollars
查看>>
SANS FOR572 Logstash
查看>>
apt成熟度模型
查看>>
Digital Forensics Framework v0.4.3 available
查看>>