mysql安装后配置
来源:互联网 发布:安卓蓝牙调试助手 源码 编辑:程序博客网 时间:2024/05/18 01:19
1:配置my.cnf
原来的配置
[root@feng02 ~]# cat /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
修改后
[root@feng02 ~]# cat /etc/my.cnf[client]password = 123456port = 3306default-character-set=utf8[mysql]default-character-set = utf8[mysqld]port = 3306character_set_server=utf8character_set_client=utf8collation-server=utf8_general_cilower_case_table_names=1max_connections=1000datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
2:初始化MySQL
输入:/usr/bin/mysql_install_db
[root@feng02 ~]# /usr/bin/mysql_install_dbInstalling MySQL system tables...150905 13:51:04 [Warning] /usr/libexec/mysqld: ignoring option '--character-set-client-handshake' due to invalid value 'utf8'OKFilling help tables...150905 13:51:04 [Warning] /usr/libexec/mysqld: ignoring option '--character-set-client-handshake' due to invalid value 'utf8'OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h feng02 password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!
3:启动Mysql
[root@feng02 ~]# service mysqld startStarting mysqld: [ OK ]
4:连接Mysql
输入:mysql -uroot -p
直接回车,不用输入密码
[root@feng02 ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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 selectedmysql> 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 1mysql> 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';
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set password=password('123456') where user='root';Query OK, 3 rows affected (0.01 sec)Rows matched: 3 Changed: 3 Warnings: 0mysql> exitBye
5:重启mysql
输入:service mysqld restart
[root@feng02 ~]# service mysqld restart
Stopping mysqld: [ OK ]Starting mysqld: [ OK ]
6:使用密码登陆:
[root@feng02 ~]# mysql -uroot -p123456Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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;
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select host,user,password from user;+-----------+------+-------------------------------------------+| host | user | password |+-----------+------+-------------------------------------------+| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 || feng02 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 || 127.0.0.1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 || localhost | | || feng02 | | |+-----------+------+-------------------------------------------+5 rows in set (0.00 sec)mysql> update user set host='%' where user='root' and host='localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.02 sec)mysql> exit;Bye
[root@feng02 ~]# mysql -uroot -p123456ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)[root@feng02 ~]# mysql -hfeng02 -uroot -p123456Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 9Server version: 5.1.73 Source distribution
0 0
- mysql安装后配置
- mysql 安装后配置失败
- MySql安装后的配置
- ubuntu安装mysql后的配置
- mysql安装后没有弹出配置向导
- Mysql MSI安装后应该如何配置?
- oracle收购Mysql后,Mysql的安装配置方法
- oracle收购Mysql后,Mysql的安装配置方法
- 吐血推荐:homebrew 安装mysql后,如何配置mysql
- Windows 下 Apache Mysql PHP 安装后的配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 安装完 MySQL 后必须调整的 10 项配置
- 翻转单词顺序
- 黑马程序员java之反射
- Android ADT 中的项目迁移到 Android Studio出现编码乱码问题
- Hadoop 案例4----平均成绩
- 黑马程序员——总集篇
- mysql安装后配置
- ToggleButton,Switch,RatingBar的使用
- php fgets函数读取多余的空格解决
- ufldl 深度学习入门 第一发:基于BP网络实现稀疏自编码器
- C++IO库
- HDU5237 Base64 大模拟
- android本地轻量级缓存
- 华为OJ 寻找大小字母个数
- 【more effective c++读书笔记】【第5章】技术(4)——Smart Pointers(智能指针)