头像

centos6.8 yum安装mysql 5.6

一、检查系统是否安装其他版本的MYSQL数据
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64

二、安装及配置
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm
yum repolist all | grep mysql
1、安装MYSQL数据库
yum install mysql-community-server -y

2、设置为开机启动
chkconfig --list | grep mysqld
chkconfig mysqld on

3、设置密码
/usr/bin/mysqladmin -u root password '123456'

4、修改root密码
mysql -uroot -p123456

mysql> select Host,User,Password from user where User='root';
+-----------------------+------+-------------------------------------------+
| Host                  | User | Password                                  |
+-----------------------+------+-------------------------------------------+
| localhost             | root | *4A82FDF1D80BA7470BA2E17FEEFD5A53D5D3B762 |
| localhost.localdomain | root |                                           |
| 127.0.0.1             | root |                                           |
| ::1                   | root |                                           |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> update user set Password = password('123456') where User='root';
Query OK, 4 rows affected (0.03 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> select Host,User,Password from user where User='root';
+-----------------------+------+-------------------------------------------+
| Host                  | User | Password                                  |
+-----------------------+------+-------------------------------------------+
| localhost             | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost.localdomain | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 127.0.0.1             | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| ::1                   | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

5、建立远程root用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你设置的密码' WITH GRANT OPTION;
mysql> flush privileges;
6、设置utf-8编码

查看mysql原本编码:
mysql> show variables like 'character%';
设置编码
# vi /etc/my.cnf
如下(少补):
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
sql_mode='NO_ENGINE_SUBSTITUTION'
[mysql]
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8
重启mysql
# service mysqld restart
再次查看编码:
# mysql -uroot -p
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)
头像

centos6.5/6.8 系统-搭建lamp(php7)环境–(yum在线安装)

1、查看当前服务器的版本

#方法1
cat /etc/redhat-release

#方法2
rpm -q centos-release

 

2、安装apache

#一键安装apache
yum install httpd

#启动apche
/etc/init.d/httpd start                     #方法1 
service httpd start                         #方法2

#设置apache开机自动启动
chkconfig --levels 235 httpd on

 

3、安装php7

#更新yum源(默认yum源中无php7)
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm  

#安装php及常用的拓展模块
yum -y install php70w php70w-mysql php70w-mbstring php70w-mcrypt php70w-gd php70w-imap php70w-ldap php70w-soap php70w-odbc php70w-pear php70w-xml php70w-xmlrpc php70w-pdo php70w-fpm

#查看php安装了那些拓展模块
php -m

#安装其他你需要的拓展模块
yum -y install php70w-xxx

 

4、安装mysql5.5

#查询是否安装了mysql,默认是安装了mysql-libs的5.1版本的。需卸载
rpm -qa|grep mysql
rpm -e mysql-libs --nodeps       #不检测依赖性

#增加两个新的repo源
rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#检测源是否安装成功
yum --enablerepo=remi,remi-test list mysql mysql-server

#安装mysql5.5
yum -y --enablerepo=remi,remi-test install mysql mysql-server

#启动mysql
/etc/init.d/mysqld start

#将mysql设置为开机自动启动
chkconfig --levels 345 mysqld on

#设置mysql的root密码
/usr/bin/mysql_secure_installation