mysql安装后配置
生活随笔
收集整理的這篇文章主要介紹了
mysql安装后配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1:配置my.cnf
原來的配置
[root@feng02 ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0[mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid修改后
[root@feng02 ~]# cat /etc/my.cnf [client] password = 123456 port = 3306 default-character-set=utf8 [mysql] default-character-set = utf8 [mysqld] port = 3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci lower_case_table_names=1 max_connections=1000 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0[mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid2:初始化MySQL
輸入:/usr/bin/mysql_install_db
3:啟動Mysql [root@feng02 ~]# service mysqld start Starting mysqld: [ OK ]
4:連接Mysql
輸入:mysql -uroot -p
直接回車,不用輸入密碼
[root@feng02 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> update user set password=password('123456') where user='root'; ERROR 1046 (3D000): No database selected mysql> show database; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec)設置root的密碼:
輸入:use mysql;
輸入:update user set password=password('123456') where user='root';
5:重啟mysql
輸入:service mysqld restart
[root@feng02 ~]# service mysqld restart
Stopping mysqld: [ OK ] Starting mysqld: [ OK ]6:使用密碼登陸: [root@feng02 ~]# mysql -uroot -p123456 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
7:設置允許遠程登錄
輸入:use mysql;
輸入:select host,user,password from user;
輸入:update user set host='%' where user='root' and host='localhost';
輸入:flush privileges;
輸入: exit;
[root@feng02 ~]# mysql -uroot -p123456 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@feng02 ~]# mysql -hfeng02 -uroot -p123456 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.1.73 Source distribution
總結
以上是生活随笔為你收集整理的mysql安装后配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Relative path in abs
- 下一篇: hive 1.1.1 Specified