Step1: 如果你系统已经有mysql,如一般centos自带mysql5.1系列,那么你需要删除它,先检查一下系统是否自带mysql
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum localinstall mysql-community-release-el6-5.noarch.rpm
yum repolist all | grep mysql
yum-config-manager --disable mysql55-community
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
yum repolist enabled | grep mysql
yum install mysql-community-server
CENTOS7上安装MYSQL5.7还有一个巨坑
之前的Linux体系中数据库大局部是mysql,不外自从被sun收买以后,便出用散成正在centos那些开源Linux体系中了,那末若是念用的话便须要本身装置了,起首centos7 已没有支撑mysql。
以前的Linux系统中数据库大部分是mysql,不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,首先centos7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以在运行以下命令前:
yum install mysql-community-server
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
service mysqld start
chkconfig --list | grep mysqld
chkconfig mysqld on
service mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
RHEL7.0系列的发行版(例如CentOs 7),特征是使用了systemd来代替原有的init,作为第一支启动的程序。此时网络上面所说的mysqld_secure已经不可使用。但是查看官方文档后,得知在这种情况下mysqld可以支持部分mysqld_safe的参数,命令如下:
mysqld --user=mysql --skip-grant-tables --skip-networking &
mysql -uroot -p
mysql> SET PASSWORD = PASSWORD('ur password here');
如果出现以下信息:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
update mysql.user set authentication_string=password('newpassword') where user='root'
update mysql.user set authentication_string=password('newpassword') where user='root'
之前的mysql版本为:
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'ur password here' WITH GRANT OPTION;
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 6M
read_rnd_buffer_size = 4M
#deprecate this option after mysql5.5 default-character-set = utf8
character-set-server=utf8
open_files_limit = 10240
back_log = 384
max_connections = 500
#deprecate this option after mysql5.5 table_cache = 512K
max_allowed_packet =16M
query_cache_size = 384M
table_open_cache = 512
key_buffer_size = 384M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
slow_query_log_file = /var/log/mysqld-slow-query.log
log-short-format
long-query-time = 3
#log-long-format
#log-slow-admin-statements
log-queries-not-using-indexes