8022
社区成员
不发文章没有积分呀,所以水一篇工作笔记,大家多多指教
# 安装MySql
## Centos 安装 MySql
[Centos8 安装 MySql5.7](https://blog.csdn.net/qq_40167917/article/details/105367225)
[菜鸟学习系列 - MySQL(Centos8.5安装MySQL8)](https://blog.csdn.net/qq_22961571/article/details/121768437)
[Centos7 查看Mysql配置文件](https://www.cnblogs.com/freewsf/p/10688448.html)
## [Ubuntu18.04 安装 MySQL](https://blog.csdn.net/weixx3/article/details/80782479)
1.安装
1.1 sudo apt-get update
1.2 sudo apt-get install mysql-server
1.3 sudo mysql_secure_installation 初始化配置。如果出错的话,先启动mysql服务器再试试
1.4 systemctl status mysql.service 检查服务状态
2.配置远程访问
2.1 sudo mysql -u root -p 用 root 用户进入
2.2 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY "123456"; 又建立了一个新的用户 名字叫 root
2.3 如何修改用户密码呢?
3.workbench连接数据库
3.1 记住上面配置的时候,自己输入的密码
3.2 mysql 服务已经开启,默认端口 3306 ,可以使用 netstat -an | findstr 3306 这个命令查看服务是否已启动
netstat -aon|findstr "1105"
tasklist | findstr "4592"
# Linux下MySql错误的解决方法
[ubuntu18.04启动Mysql报错:No directory, logging in with HOME=/ 和修改root密码,执行三条命令时加 sudo](https://blog.csdn.net/weixin_43968936/article/details/102736879)
[Linux MySQL 常见无法启动或启动异常的解决方案](https://blog.csdn.net/weixin_33928137/article/details/93120090)
[Linux MySQL 常见无法启动或启动异常的解决方案](https://www.cnblogs.com/youjianjiangnan/p/10259151.html)
[Ubuntu下查看进程PID & 终止进程方法汇总](https://blog.csdn.net/qq_43543789/article/details/104264464)
[To reset the password](https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run?page=1&tab=votes#tab-top)
ubuntu 上的数据库服务停止的时候经常失败,需要杀进程
log时间不对 修改配置文件:log_timestamps=SYSTEM ]
[记一次Linux修改MySQL配置不生效的问题](https://www.cnblogs.com/xiao2shiqi/p/11376969.html)
# Linux下MySql的操作
查看mysql版本 mysql -V,或者进入mysql 执行 select version();
查看当前mysql进程 ps -A | grep mysql 或者 ps -ef |grep mysql
产看mysql是否监听了默认的3306端口 netstat -antp| grep 3306
杀死进程 kill -9 pid
登入root进行其他设置: sudo mysql -uroot -p -A
添加用户:GRANT ALL PRIVILEGES ON 数据库名字.表名字 TO '用户名'@'%' IDENTIFIED BY "密码";
例如:GRANT ALL PRIVILEGES ON Design.* TO 'wxx'@'%' IDENTIFIED BY "dl@20210913";
显示所有库:show databases
切换到某个库: use 库名字[例如:weixx]
显示当前库内所有的表:show tables
## Ubuntu
停止服务器 sudo /etc/init.d/mysql stop
开启服务器 sudo /etc/init.d/mysql start
配置文件路径: /etc/mysql/mysql.conf.d/mysqld.cnf
## Centos
systemctl start mysqld.service 启动mysql
systemctl status mysqld.service 查看mysql状态
systemctl stop mysqld.service 关闭mysql
配置文件路径: vim /etc/my.cnf