查看端口占用情况的命令:lsof -i
查看某一端口的占用情况: lsof -i:端口号
也可使用命令:netstat -apn|grep <端口号>
1,Mac下mysql:
a. 打开mysql.dmg (http://dev.mysql.com/downloads/mysql/)
b. sequel-pro-1.0.2.dmg (http://www.sequelpro.com/download)
c. MySQL Connectors(http://dev.mysql.com/downloads/connector/)
cmake . -DBOOST_ROOT:STRING=/Users/catdoc/Downloads/boost/
make clean
make
sudo make install
2,Fedora下mysql:
yum install mysql mysql-server
用mysql做开发还需安装mysql开发库:
a. 确认已安装 mysqldev (参考 yum install mysql-devel)
b. 确认已安装 mysql++ (注意配置参数 ./configure --prefix=/usr)
3, Debian下msyql
debian:~# apt-get install mysql-server mysql-client
启动 mysql -> sudo /etc/init.d/mysql start
停止 -> /usr/bin/mysqladmin -u root -p shutdown
首次设置mysql root密码 -> /usr/bin/mysqladmin -u root password 123456
修改mysql 用户密码 -> mysqladmin -u用户名 -p旧密码 password 新密码
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
本地登录:
$mysql -u root -p // 然后在提示中输入密码
远程公路:z
mysql -h 140.134.210.131 -u root- p // -h 服务器ip
增加用户或权限:
grant all privileges on *.* to catdoc@'%' identified by '123' with grant option;
grant select,insert,update,delete on gamedb.* to sky@localhost identified by "123";
注:多条grant权限会叠加。
查看用户的权限: show grants for catdoc@"%";
只删除了用户权限,但没有删除这个用户:
revoke insert,update,delete,select ON *.* from 'catdoc'@'%' IDENTIFIED BY '123';
删除了整个用户及其权限: drop user catdoc@'localhost';
刷新权限: flush privileges;
debian的mysql配置路径 /etc/mysql/my.cnf
备份恢复:
mysql 默认的数据文件放在: /var/lib/mysql
将gamedb库备份到文件back_gamedb
su root // 需要root权限
cd /var/lib/mysql
mysqldump -u root -p --opt gamedb > back_gamedb // 备份
mysql -u root -p new_gamedb < back_gamedb // 恢复
source ~/mydata.sql // 可以导入sql文件
show databases;
create database db_mf;
use db_mf;
show tables;
create table tb_table (name varchar(20), sex char(1), birth date, addr varchar(20));
describe tb_table;
我们可以用文本文件的方式将所有记录加入你的数据库表中。
每行包含一个记录,用tab键分割
user1 f 1987-07-07 qy
user2 f 1988-12-12 gz
$load data local infile "db.txt" into table tb_table;
"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
解决方法: 执行service mysqld start 启动mysql的守护进程
查看某一端口的占用情况: lsof -i:端口号
也可使用命令:netstat -apn|grep <端口号>
1,Mac下mysql:
a. 打开mysql.dmg (http://dev.mysql.com/downloads/mysql/)
b. sequel-pro-1.0.2.dmg (http://www.sequelpro.com/download)
c. MySQL Connectors(http://dev.mysql.com/downloads/connector/)
cmake . -DBOOST_ROOT:STRING=/Users/catdoc/Downloads/boost/
make clean
make
sudo make install
2,Fedora下mysql:
yum install mysql mysql-server
用mysql做开发还需安装mysql开发库:
a. 确认已安装 mysqldev (参考 yum install mysql-devel)
b. 确认已安装 mysql++ (注意配置参数 ./configure --prefix=/usr)
3, Debian下msyql
debian:~# apt-get install mysql-server mysql-client
启动 mysql -> sudo /etc/init.d/mysql start
停止 -> /usr/bin/mysqladmin -u root -p shutdown
首次设置mysql root密码 -> /usr/bin/mysqladmin -u root password 123456
修改mysql 用户密码 -> mysqladmin -u用户名 -p旧密码 password 新密码
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
本地登录:
$mysql -u root -p // 然后在提示中输入密码
远程公路:z
mysql -h 140.134.210.131 -u root- p // -h 服务器ip
增加用户或权限:
grant all privileges on *.* to catdoc@'%' identified by '123' with grant option;
grant select,insert,update,delete on gamedb.* to sky@localhost identified by "123";
注:多条grant权限会叠加。
查看用户的权限: show grants for catdoc@"%";
只删除了用户权限,但没有删除这个用户:
revoke insert,update,delete,select ON *.* from 'catdoc'@'%' IDENTIFIED BY '123';
删除了整个用户及其权限: drop user catdoc@'localhost';
刷新权限: flush privileges;
debian的mysql配置路径 /etc/mysql/my.cnf
备份恢复:
mysql 默认的数据文件放在: /var/lib/mysql
将gamedb库备份到文件back_gamedb
su root // 需要root权限
cd /var/lib/mysql
mysqldump -u root -p --opt gamedb > back_gamedb // 备份
mysql -u root -p new_gamedb < back_gamedb // 恢复
source ~/mydata.sql // 可以导入sql文件
show databases;
create database db_mf;
use db_mf;
show tables;
create table tb_table (name varchar(20), sex char(1), birth date, addr varchar(20));
describe tb_table;
我们可以用文本文件的方式将所有记录加入你的数据库表中。
每行包含一个记录,用tab键分割
user1 f 1987-07-07 qy
user2 f 1988-12-12 gz
$load data local infile "db.txt" into table tb_table;
"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
解决方法: 执行service mysqld start 启动mysql的守护进程