Chr*_*kis 4 mysql lowercase ubuntu-18.04
我在ubuntu 18.04上安装了mysql社区服务器8.013,并且遇到以下问题。我想设置lower_case_table_names = 1,以便在数据库中使用不区分大小写的表名。我编辑了/etc/mysql/mysql.conf.d/mysqld.cnf,并在[mysqld]下添加了以下行
lower_case_table_names=1
Run Code Online (Sandbox Code Playgroud)
mysqld.cnf现在如下
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
lower_case_table_names=1
Run Code Online (Sandbox Code Playgroud)
我停止了使用
sudo service mysql stop
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用重新启动
sudo service mysql start
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Run Code Online (Sandbox Code Playgroud)
我试过了
systemctl status mysql.service
Run Code Online (Sandbox Code Playgroud)
我得到了以下信息
christoph@christoph-Latitude-E6530:/etc/init.d$ systemctl status mysql.service
? mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-11-01 16:38:14 EET; 24s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 6681 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 6642 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 6681 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 2 (No such file or directory)
??? 01 16:38:12 christoph-Latitude-E6530 systemd[1]: Starting MySQL Community Server...
??? 01 16:38:14 christoph-Latitude-E6530 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
??? 01 16:38:14 christoph-Latitude-E6530 systemd[1]: mysql.service: Failed with result 'exit-code'.
??? 01 16:38:14 christoph-Latitude-E6530 systemd[1]: Failed to start MySQL Community Server.
Run Code Online (Sandbox Code Playgroud)
使用journalctl -xe我得到以下信息
-- The result is RESULT.
??? 01 17:32:00 christoph-Latitude-E6530 sudo[2526]: pam_unix(sudo:session): session closed for user root
??? 01 17:32:04 christoph-Latitude-E6530 wpa_supplicant[743]: wlp3s0: WPA: Group rekeying completed with 4c:5e:0c:7a:95:cf [GTK=CCMP]
??? 01 17:32:08 christoph-Latitude-E6530 gnome-shell[1565]: Some code accessed the property 'discreteGpuAvailable' on the module 'appDisplay'. That property w
??? 01 17:32:08 christoph-Latitude-E6530 gnome-shell[1565]: Some code accessed the property 'WindowPreviewMenuItem' on the module 'windowPreview'. That proper
lines 1349-1371/1371 (END)
??? 01 17:31:58 christoph-Latitude-E6530 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has begun starting up.
??? 01 17:31:58 christoph-Latitude-E6530 audit[2593]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/usr/sbin/mysqld" pid=2593 comm=
??? 01 17:31:58 christoph-Latitude-E6530 kernel: kauditd_printk_skb: 28 callbacks suppressed
??? 01 17:31:58 christoph-Latitude-E6530 kernel: audit: type=1400 audit(1541086318.959:39): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name
??? 01 17:32:00 christoph-Latitude-E6530 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
??? 01 17:32:00 christoph-Latitude-E6530 systemd[1]: mysql.service: Failed with result 'exit-code'.
??? 01 17:32:00 christoph-Latitude-E6530 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
Run Code Online (Sandbox Code Playgroud)
我也尝试使用启动服务器
sudo service mysql start --initialize lower_case_table_names=1
Run Code Online (Sandbox Code Playgroud)
如这里描述的 lower_case_table_names MySQL 8.0.12中的设置, 但是我仍然遇到相同的错误,并且mysql根本无法启动
如果我运行以下
sudo vi /var/log/mysql/error.log
Run Code Online (Sandbox Code Playgroud)
我得到以下错误原因
Different lower_case_table_names settings for server ('1') and data dictionary ('0').
Data Dictionary initialization failed.
Run Code Online (Sandbox Code Playgroud)
有什么想法为什么会发生以及如何解决?
小智 10
这在带有 MySQL 8.0.20 的全新 Ubuntu Server 20.04 安装上对我有用(没有现有的数据库需要关心 - 因此如果您有重要数据,那么您应该在执行此操作之前将其备份/导出到其他地方):
所以......我做了所有具有提升权限的事情:
sudo su
Run Code Online (Sandbox Code Playgroud)
安装 MySQL(如果尚未安装):
apt-get install mysql-server
Run Code Online (Sandbox Code Playgroud)
备份配置文件,卸载,删除所有数据库和MySQL相关数据:
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.backup
service mysql stop
apt-get --purge autoremove mysql-server
rm -R /var/lib/mysql
Run Code Online (Sandbox Code Playgroud)
恢复保存的配置文件,编辑文件(在 [mysqld] 行下添加一行):
cp /etc/mysql/mysql.conf.d/mysqld.cnf.backup /etc/mysql/mysql.conf.d/mysqld.cnf
vim /etc/mysql/mysql.conf.d/mysqld.cnf
...
lower_case_table_names=1
...
Run Code Online (Sandbox Code Playgroud)
重新安装 MySQL(保留配置文件),配置其他设置:
apt-get install mysql-server
service mysql start
mysql_secure_installation
mysql
SHOW VARIABLES LIKE 'lower_case_%';
exit
Run Code Online (Sandbox Code Playgroud)
为了使此功能在MySQL 8.0和linux中遵循以下步骤
0)使用以下命令执行以下步骤之前,请备份mysql模式:
mysqldump -h localhost -u root -p mysql > /home/username/dumps/mysqldump.sql
Run Code Online (Sandbox Code Playgroud)
然后使用停止mysql
sudo service mysql stop
Run Code Online (Sandbox Code Playgroud)
1)移动或删除/ var / lib / mysql目录。这将删除所有数据库!
mv /var/lib/mysql /tmp/mysql
Run Code Online (Sandbox Code Playgroud)
2)创建一个新的/ var / lib / mysql目录,并使mysql用户成为所有者
mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
chmod 750 /var/lib/mysql
Run Code Online (Sandbox Code Playgroud)
3)编辑/etc/mysql/mysql.conf.d/mysqld.cnf并在[mysqld]之后添加以下行
lower_case_table_names=1
Run Code Online (Sandbox Code Playgroud)
4)使用以下命令初始化mysql
mysqld --defaults-file = / etc / mysql / my.cnf --initialize lower_case_table_names = 1 --user = mysql --console
用默认文件的实际位置更改默认文件。有关mysql初始化的更多信息,请访问:https : //dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html
5)(可选)重复
chown -R mysql:mysql /var/lib/mysql
chmod 750 /var/lib/mysql
Run Code Online (Sandbox Code Playgroud)
如果/ var / lib / mysql中文件的所有者不是mysql
6)使用启动mysql
sudo service mysql start
Run Code Online (Sandbox Code Playgroud)
7)如果一切正常,请使用
mysql -u root -p
Run Code Online (Sandbox Code Playgroud)
并通过运行此查询
SHOW VARIABLES where Variable_name like 'lower%';
Run Code Online (Sandbox Code Playgroud)
你会得到
'lower_case_table_names', '1'
Run Code Online (Sandbox Code Playgroud)
8)使用在步骤0中创建的转储来还原mysql模式。
9)执行mysql_upgrade创建sys模式
| 归档时间: |
|
| 查看次数: |
3597 次 |
| 最近记录: |