brew install mysql
mysql -uroot #初始没有设置密码
mysql.server start
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
/etc/mysql/my.conf
- bind-address 0.0.0.0
/etc/apache2/sites-available/default
- DocumentRoot /var/www/daloradius
sudo aptitude install -y phpmyadmin
sudo ln -s sudo ln -s /usr/share/phpmyadmin /var/www
http://IP/phpmyadmin/
CREATE USER 用户名 IDENTIFIED BY '密码';
DROP USER 用户名;
RENAME USER 原用户名 TO 新用户名;
SET PASSWORD = PASSWORD('新密码');
SET PASSWORD FOR 用户名=PASSWORD('新密码');
MySQL授予权限可分为以下几个层级:
GRANT ALL PRIVILEGES ON 层级 to 用户名@主机 IDENTIFIED BY 密码;
REVOKE ALL PRIVILEGES FROM 用户名;
mysqldump -u root -p 数据库名称 > 备份文件.sql
.mysql -u root -p 数据库名称 < 备份文件.sql
.MySQL数据库的默认编码是: character set: latin1 collation: latin1_swedish_ci
可以通过一下命令查看MySQL支持的编码: SHOW CHARACTER SET;
查看MySQL当前使用的编码: SHOW VARIABLES LIKE 'character_set%'
和 SHOW VARIABLES LIKE 'collation%'
创建数据库的时候可以使用一下命令指定编码:
CREATE DATABASE linuxcast
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
AlTER DATABASE linuxcast CHARACTER SET utf8 COLLATE utf8_general_ci;
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
collation-server=utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
修改后重启MySQL服务, 通过以下命令查看默认编码: SHOW VARAIBLES LIKE 'character_set%';