Centos 6.x 安装配置MySQL

标签: Centos 6.x mysql 中文编码
6人阅读 评论(0) 收藏 举报
分类:

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 M
Installing 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 k

Transaction Summary
=================================================================================================================================================
Install       3 Package(s)

Total download size: 9.6 M
Installed size: 27 M
Is this ok [y/N]: y

2、启动

service mysqld start
chkconfig mysqld on

[root@server ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
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/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_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 ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@server ~]# chkconfig mysqld on

3、一般配置

[root@server ~]# mysql_secure_installation




NOTE: 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 current
password for the root user.  If you've just installed MySQL, and
you 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 MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures 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 can
access.  This is also intended only for testing, and should be removed
before 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 far
will 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 MySQL
installation should now be secure.

Thanks for using MySQL!


[root@server ~]#

4、远程登录授权

[root@server ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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 -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[root@BigData01-TEST ~]#

重启

[root@server ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@server ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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> 
查看评论

centos 安装配置

  • 2011年06月26日 20:08
  • 2.62MB
  • 下载

CentOS 6.X编译安装Nginx1.6.2MySQL5.6.21PHP5.6.3(所有安装包和说明)

  • 2017年04月18日 17:15
  • 0B
  • 下载

centos安装详解

  • 2015年10月19日 20:53
  • 4.86MB
  • 下载

CentOS下安装mysql

  • 2016年03月03日 14:28
  • 55KB
  • 下载

RabbitMQ-Centos6.X环境配置

本教程借鉴博客文章地址:http://tianshili.blog.51cto.com/5050423/1638502 英文好的同学,查看官方教程:http://www.rabbitmq.com/in...
  • alex_bean
  • alex_bean
  • 2017-02-23 16:31:45
  • 1068

Centos 6安装配置图解

  • 2011年10月11日 09:47
  • 879KB
  • 下载

centOS6.X下安装MySQL

参考:http://jingyan.baidu.com/article/fec7a1e5f8d3201190b4e782.html 在/etc/my.cnf文件里加上max_allowed_...
  • zsdsywr123
  • zsdsywr123
  • 2016-09-09 21:36:51
  • 99

Linux(CentOS6.X)安装mysql6.5记录

首先执行rpm -qa|grep -i mysql检查一下是否已经安装过mysql mysql-libs-5.1.73-5.el6_6.x86_64 可见已经安装了库文件,应该先卸载,不然会出现覆...
  • vampirehgg
  • vampirehgg
  • 2017-04-21 09:38:24
  • 3510

CentOS 6.x系统管理实战宝典(全).pdf

  • 2018年02月08日 10:19
  • 167.11MB
  • 下载

Centos 6.x 安装配置 senginx

一、软件模块依赖性:  [root@localhost] # yum -y install gcc+ gcc-c++ gcc* make* libpcre.so* openssl* pcre* zl...
  • chcn00
  • chcn00
  • 2014-08-01 14:23:17
  • 926
    个人资料
    专栏达人 持之以恒
    等级:
    访问量: 31万+
    积分: 6329
    排名: 4871
    博客专栏
    最新评论