1.查看mysql安装目录
dpkg -S mysql
2.mysqlconf文件路径
/ect/mysql/my.cnf
3.mysql允许远程访问
登录mysql执行下面两个语句,意思允许外部IP访问
grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;
FLUSH PRIVILEGES;
执行上面之后还是不行,上网查了一下还需要修改my.conf把skip-network中bind address注释掉.
4.mysql启动,关闭,状态
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql status
也可以是sudo service mysql start,注意必须实用sudo或root权限。
5.查看mysql端口:
netstat -lpnut | grep mysql
----------------------------------------------------------------------------------------------------------------------------------
mysql乱码问题:
1.修改my.cnf
在[client]下添加
default-character-set=utf8
在[mysqld]下添加
default-character-set=utf8
2.重启mysql
3.查看修改效果
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.02 sec)
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| 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.02 sec)
4.jdbc的URL后面设置UTF-8编码:jdbc:mysql://127.0.0.1/ocndb?useUnicode=true&characterEncoding=utf-8
注意autoReconnect=tue没有必要实用了,参考:http://bzhang.iteye.com/blog/321832
--------------------------------------------------------------------------------
PLEASE 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 v151.cqxunmei.com password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
dpkg -S mysql
2.mysqlconf文件路径
/ect/mysql/my.cnf
3.mysql允许远程访问
登录mysql执行下面两个语句,意思允许外部IP访问
grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;
FLUSH PRIVILEGES;
执行上面之后还是不行,上网查了一下还需要修改my.conf把skip-network中bind address注释掉.
4.mysql启动,关闭,状态
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql status
也可以是sudo service mysql start,注意必须实用sudo或root权限。
5.查看mysql端口:
netstat -lpnut | grep mysql
----------------------------------------------------------------------------------------------------------------------------------
mysql乱码问题:
1.修改my.cnf
在[client]下添加
default-character-set=utf8
在[mysqld]下添加
default-character-set=utf8
2.重启mysql
3.查看修改效果
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.02 sec)
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| 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.02 sec)
4.jdbc的URL后面设置UTF-8编码:jdbc:mysql://127.0.0.1/ocndb?useUnicode=true&characterEncoding=utf-8
注意autoReconnect=tue没有必要实用了,参考:http://bzhang.iteye.com/blog/321832
--------------------------------------------------------------------------------
PLEASE 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 v151.cqxunmei.com password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!