Linux-02 mysql

mysql安装

系统环境查看

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core)

安装命令

#yum install mysql
#yum install mysql-server
#yum install mysql-devel

安装mysql和mysql-devel都成功,但是安装mysql-server失败,如下:

[root@yl-web yl]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sina.cn
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do

解决方法:官网下载解决问题

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

安装成功后重启mysql服务。

# service mysqld restart

初次安装mysql,root账户没有密码

# mysql -u root 

设置密码

mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)

再次登陆

# mysql -u root -p
# mysql -u root -p -P3306 -h 127.0.0.1

设置字符编码
mysql配置文件为/etc/my.cnf
最后加上编码配置

[mysql]
default-character-set =utf8

这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。
远程连接设置

mysql> grant all privileges on *.* to root@'%'identified by 'password';
mysql>create user 'username'@'%' identified by 'password'; 
posted @ 2018-08-05 19:37  可乐8848  阅读(84)  评论(0)    收藏  举报