8.0之后的sql毛病是真多,把这些常用的命令的都记录下来以备后用。里面包含了从安装到使用,远程登录,密码,redis,等等问题。
# Ubuntu
sudo service mysql stop
sudo usermod -d /var/lib/mysql/ mysql
sudo service mysql start
sudo apt-get install mysql-server //服务端
sudo apt-get install mysql-client //客户端
sudo apt-get install libmysqlclient-dev //程序编译时链接库
启动mysql:
方式一:sudo /etc/init.d/mysql start
方式二:sudo service mysql start
停止mysql:
方式一:sudo /etc/init.d/mysql stop
方式二:sudo service mysql stop
重启mysql:
方式一:sudo/etc/init.d/mysql restart
方式二:sudo service mysql restart
debian-sys-maint
sudo apt autoremove --purge mysql* // 卸载删除
use mysql;
// 下面这句命令有点长,请注意。
update user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
update user set plugin='mysql_native_password' where user='root'; #更改加密方式
alter user 'root'@'localhost' IDENTIFIED BY '123456'; #设置密码
FLUSH PRIVILEGES;
dpyWLEXpJq4nlMhC
sudo vi /etc/mysql/my.cnf //修该配置文件
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
sudo cat /etc/mysql/debian.cnf
skip-grant-tables
select user ,host from user;
CREATE USER 'root'@'自己ip' IDENTIFIED WITH mysql_native_password BY '密码'; //创建用户
//alter user 'root'@'自己ip' identified by 'zxc123';
alter user 'root'@'自己ip' identified with mysql_native_password by '密码'; //修改用户
alter user 'root'@'localhost' identified with mysql_native_password by '密码';
grant all privileges on *.* to 'root'@'自己ip' identified by '密码' with grant option; //授所有权
grant all privileges on *.* to 'root'@'自己ip' with grant option; // 授权 传授权限
show grants for root@'localhost'; //查看权限
delete from user where user = 'root' and host = '169.254.69.135'; //删除用户
lsof -i:3306 //端口命令
drop user `mysql.infoschema`@"localhost";
// 这个部分`mysql.infoschema`@"localhost"就是连接数据库报错提示的用户与地址
flush privileges;
//刷新权限
create user `mysql.infoschema`@"localhost" identified by 'h102';
//`mysql.infoschema`@"localhost" 这个也要改成你报错的用户与地址
flush privileges;
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.47.130' IDENTIFIED BY '00hh12' WITH GRANT OPTION;
GRANT PROXY ON ''@'' TO 'root'@'192.168.47.130' WITH GRANT OPTION;
update user set Select_priv = 'Y' where User = 'mysql.infoschema';
//这里注意用户名,也是你报错的用户名
flush privileges;
DNS
sudo vi /etc/systemd/resolved.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTENnameserver 127.0.1.1
#这里用的是阿里云的DNS服务器
vim /etc/resolv.conf
nameserver 223.5.5.5
nameserver 223.6.6.6
# 换源
sudo vim /etc/apt/sources.list
# 将源文件里的内容全部替换为如下内容:
#redis 安装
sudo apt-get install redis-server
#配置文件修改
sudo vi /etc/redis/redis.conf
# 设置端口 port
# 设置密码 requirepass
# 启用远程登录
1) 注释 bind
2) protected-mode 设置为 no
# 启动 redis 服务
service redis-server start
# 关闭 redis 服务
service redis-server stop
# 重启 redis 服务
service redis-server restart
# 查看 redis 状态
service redis-server status
#刷新DB数据
flushall
protected-mode no
#hiredis
git clone https://github.com/redis/hiredis.git
2.cd hiredis
3.make
4.make install
5.sudo ldconfig (更新动态库配置文件)
6.cd hiredis/example
7.gcc example.c -o example -I /usr/local/include/hiredis -lhiredis
#boost
apt-cache search boost
搜到所有的boost库
然后:
sudo apt-get install libboost-all-dev
安装相应的库
#"libtoolize" on Ubuntu
sudo apt-get install aptitude
sudo aptitude install libtool
#查看进程命令
ps -ef | grep mysql
#查看端口号
netstat -tunlp | grep