新裝mysql版本 mysql-5.5.56.tar.gz cmake-2.8.6.tar.gz 系統爲centos6.8html
編譯後啓動報錯 :mysql
Starting MySQL..The server quit without updating PID file ([FAILED]al/mysql/data/iZwz92ycxa8b5l94ufhgbcZ.pid).
tail -f /usr/local/mysql/data/iZwz92ycxa8b5l94ufhgbcZ.err
查看日誌文件出現以下一條:sql
180419 12:27:49 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
通過查閱資料得知。要敲以下命令解決:數據庫
cd /usr/local/mysql/scripts/
./mysql_install_db –usrer=mysql datadir=/usr/local/mysqlcentos
出現錯誤:服務器
FATAL ERROR: Could not find ./bin/my_print_defaults (本應該存在於安裝mysql目錄下)併發
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.socket
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
告訴我沒有找到 ./bin/my_print_defaults 可在ls -l bin下有學習
以後百度一下有各類方法其中一種小白沒有試過 附上地址:ui
https://blog.csdn.net/m0_37975886/article/details/78329341?locationNum=7&fps=1
有朋友嘗試過還望告訴小白一塊兒學習
我採用的另一種方法:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
啓動:
[root@iZwz92ycxa8b5l94ufhgbcZ bin]# service mysqld start
Starting MySQL.. [ OK ]
由於是新安裝因此直接admin形式修改密碼 mysqladmin -u root password "密碼"
select host, user from user;
+-------------------------+------+
| host | user |
+-------------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| izwz92ycxa8b5l94ufhgbcz | |
| izwz92ycxa8b5l94ufhgbcz | root |
| localhost | |
| localhost | root |
+-------------------------+------
須要遠程鏈接須要新受權:
進入數據庫:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
(百分號也可換成容許訪問的ip 配合iptables使用)
flush privileges; 刷新權限
查看可鏈接訪問的限定:
use mysql;
select host,user from user;
+----------------+------+
| host | user |
+----------------+------+
| 127.0.0.1 | root |
| % | root |
| localhost | root |
+----------------+------+
3 rows in set (0.00 sec)
如若忘記密碼須要重置
https://www.cnblogs.com/itor/p/6339505.html
ERROR 1040 (HY000): Too many connections
鏈接已達最大值
可用netstat -anput |grep 3306 |wc -l 查看有多少使用3306端口訪問或者進入mysql數據庫
mysql> show status like '%connect%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Aborted_connects | 0 |
| Connections | 11 |
| Max_used_connections | 5 |
| Threads_connected | 5 |
+----------------------+-------+
4 rows in set (0.00 sec)
Threads_connected 當前的鏈接數,Connections 試圖鏈接到(無論是否成功)MYSQL服務器的鏈接總數, Max_used_connections 服務器啓動後已經同時使用過的鏈接最大數量(併發)。
mysql> show global variables like 'port'; # 查看MySQL運行的實際端口
修改有兩種方法:
第一:
mysql>select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS'; 查看設置的最大是多少
mysql> set global max_connections = 3600; 修改成3600最大值
第二:
直接修改/etc/my.cnf
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
max_connections=1000
修改後須要重啓服務
#################################################
新建用戶:CREATE USER ‘username'@'localhost' IDENTIFIED BY ‘password';
username 用戶名
localhost 容許鏈接的範圍 注意iptables限制
password 設置密碼
用戶已建立完成 但此時並無對其已存在數據庫進行受權 所以username並無對其餘數據庫的操做權限
GRANT ALL ON *.* TO 'username'@'%';
ALL 全部權限
CREATE: 建立庫、表和索引
LOCK_TABLES: 鎖定表
ALTER: 修改表
DELETE: 刪除表
INSERT: 插入表或列
SELECT: 檢索表或列的數據
CREATE_VIEW: 建立視圖
SHOW_DATABASES: 列出數據庫
DROP: 刪除庫、表和視圖
*.* 選中全部庫及其全部表
新增或設置最後 FLUSH PRIVILEGES;