SonarQube之Mysql安裝

Mysql 從5.1升級到5.6安裝


轉:https://www.cnblogs.com/007sx/p/7083143.html


一、檢查系統是否安裝其他版本的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


安裝MYSQL數據庫
# yum install mysql-community-server -y
設置爲開機啓動(2、3、4都是on代表開機自動啓動)
# chkconfig --list | grep mysqld
# chkconfig mysqld on


三、設置遠程root
啓動mysql
# service mysqld start


##啓動失敗報錯 ##
[root@localhost ~]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

查看log
2018-01-08 23:05:45 7253 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2018-01-08 23:05:45 7253 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2018-01-08 23:05:45 7253 [ERROR] Plugin 'InnoDB' init function returned error.
2018-01-08 23:05:45 7253 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-01-08 23:05:45 7253 [ERROR] Unknown/unsupported storage engine: InnoDB
2018-01-08 23:05:45 7253 [ERROR] Aborting

檢查發現mysql的目錄下有如下文件:
[root@tserver mysql]# ls
ibdata1  ib_logfile0  ib_logfile1  mysql  RPM_UPGRADE_HISTORY  RPM_UPGRADE_MARKER-LAST  test  tserver.err
刪除了如下三個文件:
[root@tserver mysql]# rm ibdata1  ib_logfile0  ib_logfile1 
rm: remove regular file `ibdata1'? yes       
rm: remove regular file `ib_logfile0'? yes
rm: remove regular file `ib_logfile1'? yes
重新啓動mysql server就可以了:
cd /var/lib/mysql
[root@localhost mysql]# service mysqld start
Starting mysqld:                                           [  OK  ]




設置root密碼
# mysql_secure_installation




登陸root賬號
# mysql -u root -p 123456


##密碼報錯##
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解決方法:https://www.cnblogs.com/gumuzi/p/5711495.html
#vim /etc/my.cnf(注:windows下修改的是my.ini)
1.在[mysqld]後面任意一行添加“skip-grant-tables”用來跳過密碼驗證的過程,如下圖所示
2.接下來我們需要重啓MySQL:
/etc/init.d/mysql restart(有些用戶可能需要使用/etc/init.d/mysqld restart或service mysqld restart)
3.重啓之後輸入#mysql即可進入mysql。
4.接下來就是用sql來修改root的密碼

mysql> use mysql;
mysql> update user set password=password("你的新密碼") where user="root";
mysql> flush privileges;
mysql> quit
到這裏root賬戶就已經重置成新的密碼了。
5.編輯my.cnf,去掉剛纔添加的內容,然後重啓MySQL。大功告成!

查看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)






===============================================================================================






sonarqube下載地址:https://sonarsource.bintray.com/Distribution/sonarqube/  or   http://www.sonarqube.org/downloads/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章