Step1: 若是你係統已經有mysql,如通常centos自帶mysql5.1系列,那麼你須要刪除它,先檢查一下系統是否自帶mysqlhtml
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的文件衝突,因此在運行如下命令前:
node
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的參數,命令以下:mysql
mysqld --user=mysql --skip-grant-tables --skip-networking &
mysql -uroot -p
mysql> SET PASSWORD = PASSWORD('ur password here');
若是出現如下信息:sql
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