新闻中心
新闻中心与新手教程
新闻中心与新手教程
发布时间:2024-10-04 18:44:06
sudo apt update
sudo apt upgrade
sudo apt install mysql-serversudo systemctl status mysqlsudo mysql_secure_installationsudo mysqlcreate user 'newuser'@'localhost' identified by 'password';
grant all privileges on *.* to 'newuser'@'localhost';
flush privileges;
exit;
症状:systemctl status mysql 显示服务无法启动
解决方法:
sudo tail -f /var/log/mysql/error.logsudo chown -r mysql:mysql /var/lib/mysql
sudo chmod 755 /var/lib/mysql
df -h症状:mysql -u root -p 命令无法连接
解决方法:
sudo systemctl start mysqlbind-address 设置:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnfbind-address = 127.0.0.1 或注释掉该行sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set authentication_string=password('newpassword') where user='root';
flush privileges;
exit;
sudo systemctl restart mysql症状:安装或启动时报内存不足错误
解决方法:
sudo fallocate -l 2g /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnfinnodb_buffer_pool_size = 256m症状:安装时报依赖错误
解决方法:
sudo apt --fix-broken installsudo apt update
sudo apt install -f
sudo apt install mysql-server
症状:mysql无法启动,日志显示端口被占用
解决方法:
sudo netstat -tuln | grep 3306sudo nano /etc/mysql/mysql.conf.d/mysqld.cnfport = 3306 为其他未使用的端口sudo systemctl restart mysqlinnodb_buffer_pool_size:设置为系统内存的50-80%记住,在进行任何重大更改之前,务必备份您的数据库。如果您不确定某些操作,建议在测试环境中先尝试。
感谢提供:05互联