Reinstall mysql-server after upgrade to Ubuntu 18.04 - errors - mysql

Mysql needed to be reinstalled after I upgraded to Ubuntu 18.04. I did 'sudo service mysqld stop' before the upgrade, and then the cleanup step must have removed mysql server. When it wasn't found I did:
sudo apt-get remove mysql-server
sudo apt-get install mysql-server
...
Setting up mysql-server-5.7 (5.7.22-0ubuntu18.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
Please enable --log-error option or set appropriate redirections for standard output and/or standard error in daemon mode.
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
Please enable --log-error option or set appropriate redirections for standard output and/or standard error in daemon mode.
Warning: Unable to start the server.
...
I then ran 'systemctl status mysql.service' which reported this:
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.828124Z 0 [ERROR] InnoDB: Operating system error number 2 in a file oper
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.828132Z 0 [ERROR] InnoDB: The error means the system cannot find the pat
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.828140Z 0 [ERROR] InnoDB: Could not find a valid tablespace file for `my
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.828199Z 0 [Warning] InnoDB: Cannot calculate statistics for table `mysql
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.828232Z 0 [ERROR] Can't open and lock privilege tables: Tablespace is mi
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.846964Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180719 11:21:4
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.934673Z 0 [Note] Event Scheduler: Loaded 0 events
Jul 19 11:21:49 steve-VAIO mysqld[6106]: 2018-07-19T18:21:49.934950Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Jul 19 11:21:49 steve-VAIO mysqld[6106]: Version: '5.7.22-0ubuntu18.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu
Jul 19 11:21:49 steve-VAIO systemd[1]: Started MySQL Community Server.
mysqld is running and my databases are available, but I'm sure this will bite me again when it updates. phpMyAdmin shows the mysql database, which seems healthy. At the top of the list of databases is one called '#mysql50#mysql.bkp'.
Any suggestions for cleaning this up?
After suggestion to run mysql_upgrade, I did:
steve#steve-VAIO:~/workspace/JavascriptCourse$ mysql_upgrade -u root -p
mysql_upgrade: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
Enter password:
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
mysql_upgrade: [ERROR] 1812: Tablespace is missing for table `mysql`.`plugin`.
So I'll hunt for a fix for this table's tablespace.

Related

Mac Big Sur MariaDB will not run

MariaDB has worked fine but is now failing to run on boot up. I have uninstalled and it then reinstalled it and this does not fix anything.
Here is the output from mysql.server.start
mysql.server start
Starting MariaDB
.210913 10:08:11 mysqld_safe Logging to '/usr/local/var/mysql/xxxx-MacBookPro.local.err'.
210913 10:08:11 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
/usr/local/bin/mysql.server: line 264: kill: (4944) - No such process
ERROR!
This is what I get from brew info mariadb
mariadb: stable 10.6.4 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with:
mariadb-connector-c (because both install `mariadb_config`)
mysql (because mariadb, mysql, and percona install the same binaries)
mytop (because both install `mytop` binaries)
percona-server (because mariadb, mysql, and percona install the same binaries)
/usr/local/Cellar/mariadb/10.6.4 (902 files, 183MB) *
Poured from bottle on 2021-09-13 at 09:49:21
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/mariadb.rb
License: GPL-2.0-only
==> Dependencies
Build: bison ✘, cmake ✘, pkg-config ✘
Required: groonga ✔, openssl#1.1 ✔, pcre2 ✔
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To have launchd start mariadb now and restart at login:
brew services start mariadb
Or, if you don't want/need a background service you can just run:
mysql.server start
==> Analytics
install: 13,312 (30 days), 41,010 (90 days), 166,455 (365 days)
install-on-request: 13,289 (30 days), 40,949 (90 days), 165,680 (365 days)
build-error: 0 (30 days)
Here is what I get from brew services list
dnsmasq stopped
httpd error xxxx /usr/local/opt/httpd/homebrew.mxcl.httpd.plist
mariadb xxxx /usr/local/opt/mariadb/homebrew.mxcl.mariadb.plist
mysql#5.7 xxxx /usr/local/opt/mysql#5.7/homebrew.mxcl.mysql#5.7.plist
nginx stopped
php#5.6 stopped
php#7.0 stopped
php#7.3 stopped
php#7.4 stopped
The mac is serving up PHP successfully which throws a "Connection Refused" error when the code tries to talk to the database. So, I don't really understand the httpd error if apache appears to be operating.
Here is the contents of the err log (thank you DanBlack)
This is from the /usr/local/var/mysql/xxxx-MacBookPro.local.err
2021-09-16T15:30:12.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/XXXX-MacBookPro.local.pid ended
210916 17:30:13 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
2021-09-16 17:30:13 0 [Note] /usr/local/opt/mariadb/bin/mariadbd (server 10.6.4-MariaDB) starting as process 33244 ...
2021-09-16 17:30:13 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
/usr/local/opt/mariadb/bin/mariadbd: Please consult the Knowledge Base to find out how to run mysqld as root!
2021-09-16 17:30:13 0 [ERROR] Aborting
210916 17:30:13 mysqld_safe mysqld from pid file /usr/local/var/mysql/XXXX-MacBookPro.local.pid ended
2021-09-16T15:30:21.6NZ mysqld_safe Logging to '/usr/local/var/mysql/XXXX-MacBookPro.local.err'.
2021-09-16T15:30:21.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2021-09-16T15:30:21.651835Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-09-16T15:30:21.652151Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-09-16T15:30:21.652197Z 0 [Note] /usr/local/opt/mysql#5.7/bin/mysqld (mysqld 5.7.35) starting as process 33337 ...
2021-09-16T15:30:21.655210Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2021-09-16T15:30:21.656555Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-09-16T15:30:21.656576Z 0 [Note] InnoDB: Uses event mutexes
2021-09-16T15:30:21.656585Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-09-16T15:30:21.656593Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-09-16T15:30:21.658530Z 0 [Note] InnoDB: Number of pools: 1
2021-09-16T15:30:21.658624Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-09-16T15:30:21.659813Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-09-16T15:30:21.668320Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-09-16T15:30:21.719277Z 0 [ERROR] InnoDB: Only one log file found.
2021-09-16T15:30:21.719324Z 0 [ERROR] InnoDB: Plugin initialization aborted with error not found
2021-09-16T15:30:22.233348Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-09-16T15:30:22.233372Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-09-16T15:30:22.233382Z 0 [ERROR] Failed to initialize builtin plugins.
2021-09-16T15:30:22.233390Z 0 [ERROR] Aborting
2021-09-16T15:30:22.233402Z 0 [Note] Binlog end
2021-09-16T15:30:22.233465Z 0 [Note] Shutting down plugin 'CSV'
2021-09-16T15:30:22.233770Z 0 [Note] /usr/local/opt/mysql#5.7/bin/mysqld: Shutdown complete
This keeps repeating every few seconds.
However, I can now connect to the localhost mysql server and run things using mysql databases # 127.0.0.1 having deleted /usr/local/var/mysql/ib_logfile0
Ran into the same problem. Mariadb was conflicting with a previous mysql installation on my M1 mac.
Removed /opt/homebrew/var/mysql/ folder and reinstalled mariadb. Works fine now.

vagrant shared storage - docker container mysql - persistent volume - not coming up

I tried multiple times with no luck and the results are going nowhere.
My set up is something like this:
windows 10 host
virtual box latest version
guest VM is ubuntu latest minimal (command line)
using vagrant to create VMs and share folders between host and guest VM
My code, Dockerfile, and Docker-compose files are saved in shared folder say (/vagrant/test) so I can easily access them from the Windows host.
From guest VM: (file permissions)
vagrant#dev-env-testing:/vagrant/test$ ll
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 12:33 ./
drwxr-xr-x 23 root root 4096 Apr 14 12:50 ../
drwxrwxrwx 1 vagrant vagrant 0 Apr 14 10:30 .vagrant/
-rwxrwxrwx 1 vagrant vagrant 1072 Apr 14 13:36 Vagrantfile*
-rwxrwxrwx 1 vagrant vagrant 0 Apr 19 11:23 a*
drwxrwxrwx 1 vagrant vagrant 0 Apr 19 12:33 code/
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 12:28 mysql-data/
-rwxrwxrwx 1 vagrant vagrant 0 Apr 19 12:29 mysqlcontainer_bug_sharefolder.txt*
I also added the user "vagrant" in the group: 999(systemd-coredump)
vagrant#dev-env-testing:/vagrant$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lxd),997(docker),999(systemd-coredump)
For testing I'm using this command to create a container:
docker run -d --name=test-mysql4 -e MYSQL_ROOT_PASSWORD=mypassword -p 6604:3306 -v /vagrant/mysql-data:/var/lib/mysql MySQL
here, I'm trying to create a persistent volume (mounted on a host shared folder /vagrant/mysql-data) for my_sql container but the container creation is failing.
Scenario 1:
/vagrant/mysql-data: has no data in this folder.
docker logs test-mysql4
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T12:28:37.465722Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-04-19T12:28:37.472616Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2021-04-19T12:28:37.478227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-19T12:28:41.252791Z 0 [ERROR] [MY-012592] [InnoDB] Operating system error number 95 in a file operation.
2021-04-19T12:28:41.252961Z 0 [ERROR] [MY-012596] [InnoDB] Error number 95 means 'Operation not supported'
2021-04-19T12:28:41.253274Z 0 [ERROR] [MY-012646] [InnoDB] File ./undo_001: 'Linux aio' returned OS error 195. Cannot continue operation
2021-04-19T12:28:41.253413Z 0 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
or I get this error
Scenario 2:
/vagrant/mysql-data: has below files,
/vagrant/mysql-data$ ls
'#ib_16384_0.dblwr' '#ib_16384_1.dblwr' ib_logfile1 ib_logfile101
ibdata1 undo_001 undo_002 undo_1_trunc.log undo_2_trunc.log
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T12:25:20.641591Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-04-19T12:25:20.645008Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-04-19T12:25:20.645019Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-04-19T12:25:20.645069Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-19T12:25:20.645195Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
vagrant#rma-dev-env-testing:/vagrant/mysql-data$ ls
Any help is greatly appreciated.
Thanks in advance

Mysql serivce can't start it, with the control process exited with error code problem

my os is Redhat8.
currtenly I install Mysql, version is "mysql Ver 8.0.13 for Linux on x86_64 (Source distribution)"
I use command "sudo yum install mysql, mysql-server"
But i get error when i want to start mysql services. I keep finding soluction, but still I don't know how to solved it.
Can anyone help me to look at it?
#--------------------------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
# --------------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-02-19 12:12:15 AST; 15s ago
Process: 13080 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 13052 ExecStart=/usr/libexec/mysqld --basedir=/usr (code=exited, status=1/FAILURE)
Process: 13015 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 12991 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 13052 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 2 (No such file or directory)
Feb 19 12:12:12 systemd[1]: Starting MySQL 8.0 database server...
Feb 19 12:12:15 systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
Feb 19 12:12:15 systemd[1]: mysqld.service: Failed with result 'exit-code'.
Feb 19 12:12:15 systemd[1]: Failed to start MySQL 8.0 database server.
# ----------------------------------------------------------------------------------------
[yliu#rhlab1 ~]$ sudo cat /var/log/mysql/mysqld.log | nl | tail -n 10
38 2020-02-19T15:48:25.492390Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.13) Source distribution.
39 2020-02-19T15:48:25.492468Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.
40 2020-02-19T16:12:13.332724Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.13) starting as process 13052
41 2020-02-19T16:12:13.585641Z 1 [ERROR] [MY-010781] [Server] Found ./mysql/index_stats.frm file in mysql schema. DD will create .ibd file with same name. Please rename table and start upgrade process again.
42 2020-02-19T16:12:13.585666Z 1 [ERROR] [MY-010336] [Server] Found .frm file with same name as one of the Dictionary Tables.
43 2020-02-19T16:12:13.585833Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
44 2020-02-19T16:12:13.585871Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it.
45 2020-02-19T16:12:13.585881Z 0 [ERROR] [MY-010119] [Server] Aborting
46 2020-02-19T16:12:15.000469Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.13) Source distribution.
47 2020-02-19T16:12:15.000550Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.
My /etc/my.cnf.d/mysql-server.cnf information is:
[yliu#rhlab1 ~]$ sudo cat /etc/my.cnf.d/mysql-server.cnf
#
# This group are read by MySQL server.
# Use it for options that only the server (but not clients) should see
#
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
I solved the problem, hope it will helpful for everyone who meet the same problem.
Base on the log:
41 2020-02-19T16:12:13.585641Z 1 [ERROR] [MY-010781] [Server] Found ./mysql/index_stats.frm file in mysql schema. DD will create .ibd file with same name. Please rename table and start upgrade process again.
42 2020-02-19T16:12:13.585666Z 1 [ERROR] [MY-010336] [Server] Found .frm file with same name as one of the Dictionary Tables.
43 2020-02-19T16:12:13.585833Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
44 2020-02-19T16:12:13.585871Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it.
so we can remove all the files under /var/lib/mysql/
and then make sure the mysql file owner and group are mysql.
(Django) [yliu#rhlab1 ops]$ sudo ls -al /var/lib/ | grep mysql
drwxr-xr-x. 7 mysql mysql 4096 Feb 24 10:16 mysql
and then you can start mysqld again
sudo systemctl start mysqld

MariaDB 10 CentOS 7 moving datadir woes

Brand new "minimal" install of CentOS 7 along with MariaDB 10. I have an additional mounted mirrored volume that I want to use for the datadir. Startup sequence is fine and completes normally when my.cnf [mysqld] is commented out. I've copied the data..
sudo cp -R -p /var/lib/mysql/* /mnt/mysql/
The permissions are identical to those of the original. The volume is in /etc/fstab and mounts fine
/dev/sdb1 /mnt/mysql xfs defaults 0 0
[root#femur mysql]# ls -la
total 110632
drwxr-xr-x. 5 mysql mysql 4096 Oct 20 15:27 .
drwxr-xr-x. 3 root root 18 Oct 16 16:46 ..
-rw-rw----. 1 mysql mysql 16384 Oct 20 15:27 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Oct 20 15:27 aria_log_control
-rw-r-----. 1 mysql root 7005 Oct 20 13:49 femur.err
-rw-rw----. 1 mysql mysql 12582912 Oct 20 15:27 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Oct 20 15:27 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Oct 20 12:21 ib_logfile1
-rw-rw----. 1 mysql mysql 0 Oct 20 12:22 multi-master.info
drwx--x--x. 2 mysql mysql 4096 Oct 20 12:21 mysql
drwx------. 2 mysql mysql 4096 Oct 20 13:37 performance_schema
drwxr-xr-x. 2 mysql mysql 6 Oct 20 12:21 test
this is in my.cnf
!includedir /etc/my.cnf.d
[mysqld]
log_error = /var/log/mysql-error.log
user = mysql
datadir = /mnt/mysql
socket = /mnt/mysql/mysql.sock
This is what I get when I try to start it...
'[root#femur mysql]# sudo systemctl start mysql.service
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.'
Neither of those two files says much, but this is in /var/log/mysql-error.log
141020 16:07:09 mysqld_safe Starting mysqld daemon with databases from /mnt/mysql
141020 16:07:09 [Warning] Can't create test file /mnt/mysql/femur.lower-test
141020 16:07:09 [Note] InnoDB: Using mutexes to ref count buffer pool pages
141020 16:07:09 [Note] InnoDB: The InnoDB memory heap is disabled
141020 16:07:09 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
141020 16:07:09 [Note] InnoDB: Memory barrier is not used
141020 16:07:09 [Note] InnoDB: Compressed tables use zlib 1.2.7
141020 16:07:09 [Note] InnoDB: Using Linux native AIO
141020 16:07:09 [Note] InnoDB: Using CPU crc32 instructions
141020 16:07:09 [Note] InnoDB: Initializing buffer pool, size = 128.0M
141020 16:07:09 [Note] InnoDB: Completed initialization of buffer pool
2014-10-20 16:07:09 7f6cb59c9880 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
141020 16:07:09 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
141020 16:07:09 [ERROR] InnoDB: The system tablespace must be writable!
141020 16:07:09 [ERROR] Plugin 'InnoDB' init function returned error.
141020 16:07:09 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141020 16:07:09 [ERROR] mysqld: File '/mnt/mysql/aria_log_control' not found (Errcode: 13 "Permission denied")
141020 16:07:09 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/mnt/mysql/aria_log_control'
141020 16:07:09 [ERROR] Plugin 'Aria' init function returned error.
141020 16:07:09 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
141020 16:07:09 [Note] Plugin 'FEEDBACK' is disabled.
141020 16:07:09 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
141020 16:07:09 [ERROR] Unknown/unsupported storage engine: InnoDB
141020 16:07:09 [ERROR] Aborting
141020 16:07:09 [Note] /usr/sbin/mysqld: Shutdown complete
141020 16:07:09 mysqld_safe mysqld from pid file /mnt/mysql/femur.pid ended
http://www.reddit.com/r/linuxadmin/comments/2ebhpf/adventures_in_moving_mariadb_data_folder/ helped a bit, but I wasn't able to get it to work.
Any help would be greatly appreciated.
The issue is indeed SELinux; you need to do three things before MariaDB / MySQL will start on CentOS 7:
Ensure the user:group is mysql:mysql
Set the SELinux tag to mysqld_db_t
Set the SELinux user to system_u
This is as simple as:
chcon -Rt mysqld_db_t /database/db
chcon -Ru system_u /database/db
chown -R mysql:mysql /database/db
The whole thing I needed to do after plugging in a disk is below:
cfdisk /dev/sdb
pvcreate /dev/sdb1
vgcreate database /dev/sdb1
lvcreate -l 100%FREE -n db database
mkfs.ext4 /dev/database/db
mkdir /database
mount /database
mkdir /database/db
chcon -Rt mysqld_db_t /database/db
chcon -Ru system_u /database/db
chown -R mysql:mysql /database/db
systemctl start mariadb
Well that was interesting...
It turns out, that CentOS 7 "minimal" installs SELinux, which apparently was preventing mysql from writing to the mounted mirrored set. I was looking for security items that I might not have thought about and found it right there in the docs. I had previously thought (obviously erroneously) that SELinux was a distribution, not a module. Once I ran the test to see if it was there....
getenforce
I temporarily disabled it to test.
setenforce 0
Finally, I was able to start MariaDB with the directory in the mirrored set as the datadir and no errors. To make this change permanent (because this server is behind a firewall), in /etc/selinux/config, I made
- SELINUX=enforcing
+ SELINUX=disabled
I hope this helps someone else. Have a great day!
I found this step by step guide working for me: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/SELinux_Users_and_Administrators_Guide/sect-Managing_Confined_Services-MariaDB-Configuration_Examples.html
You must install:
yum install policycoreutils-python
Guide:
View the SELinux context of the default database location for mysql:
~]# ls -lZ /var/lib/mysql
drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql
This shows mysqld_db_t which is the default context element for the location of database files. This context will have to be manually applied to the new database location that will be used in this example in order for it to function properly.
Stop the mysqld daemon:
~]# systemctl stop mariadb.service
Create a new directory for the new location of the database(s). In this example, /mysql/ is used:
~]# mkdir -p /mysql
Copy the database files from the old location to the new location:
~]# cp -R /var/lib/mysql/* /mysql/
Change the ownership of this location to allow access by the mysql user and group. This sets the traditional Unix permissions which SELinux will still observe:
~]# chown -R mysql:mysql /mysql
Run the following command to see the initial context of the new directory:
~]# ls -lZ /mysql
drwxr-xr-x. mysql mysql unconfined_u:object_r:usr_t:s0 mysql
The context usr_t of this newly created directory is not currently suitable to SELinux as a location for MariaDB database files. Once the context has been changed, MariaDB will be able to function properly in this area.
Open the main MariaDB configuration file /etc/my.cnf with a text editor and modify the datadir option so that it refers to the new location. In this example the value that should be entered is /mysql:
[mysqld]
datadir=/mysql
Save this file and exit.
Start mysqld. The service should fail to start, and a denial message will be logged to the /var/log/messages file:
~]# systemctl start mariadb.service
Job for mariadb.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.
However, if the audit daemon is running and with him the setroubleshoot service, the denial will be logged to the /var/log/audit/audit.log file instead:
SELinux is preventing /usr/libexec/mysqld "write" access on /mysql. For complete SELinux messages. run sealert -l b3f01aff-7fa6-4ebe-ad46-abaef6f8ad71
The reason for this denial is that /mysql/ is not labeled correctly for MariaDB data files. SELinux is stopping MariaDB from having access to the content labeled as usr_t. Perform the following steps to resolve this problem:
Run the following command to add a context mapping for /mysql/. Note that the semanageutility is not installed by default. If it missing on your system, install the policycoreutils-pythonpackage.
**~]# semanage fcontext -a -t mysqld_db_t "/mysql(/.*)?"**
This mapping is written to the /etc/selinux/targeted/contexts/files/file_contexts.local file:
~]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local
/mysql(/.*)? system_u:object_r:mysqld_db_t:s0
Now use the restorecon utility to apply this context mapping to the running system:
**~]# restorecon -R -v /mysql**
Now that the /mysql/ location has been labeled with the correct context for MariaDB, mysqldstarts:
~]# systemctl start mariadb.service
Confirm the context has changed for /mysql/:
~]$ ls -lZ /mysql
drwxr-xr-x. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql
The location has been changed and labeled, and mysqld has started successfully. At this point all running services should be tested to confirm normal operation.

MYSQL Unable to start the service

I just downloaded MySQL 5.0.9 source code and build and installed as root user:
./configure
./make
./make install
Now I am trying to bring up mysqld but the error says:
[root libexec]# ./mysqld
120718 7:37:09 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists!
120718 7:37:09 [ERROR] Aborting
120718 7:37:09 [Note] ./mysqld: Shutdown complete
[root libexec]#
Note that I did all my activity as a root user and am trying to start the service for the very first time itself?
I did what user868766 stated below but was unable to successfully execute last command. However now I get something else while trying to invoke it directly:
BTW how do we set the MySQL root password?
[root libexec]# ./mysqld
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
120718 7:52:35 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
120718 7:52:35 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
120718 7:52:35 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
120718 7:52:35 InnoDB: Started; log sequence number 0 0
120718 7:52:35 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
I just ran as per info present in the link provided by user868766:
[root bin]# mysql_install_db
Note using command other than that was giving issues:
[root bin]# mysql_install_db -user=mysql -ldata=/opt/mysql/mysql/data
Installing MySQL system tables...
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line
/usr/local/libexec/mysqld: File 'data=/opt/mysql/mysql/data' not found (Errcode: 2)
120718 8:35:00 [ERROR] Could not use data=/opt/mysql/mysql/data for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
OK
Filling help tables...
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line
/usr/local/libexec/mysqld: File 'data=/opt/mysql/mysql/data' not found (Errcode: 2)
120718 8:35:00 [ERROR] Could not use data=/opt/mysql/mysql/data for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h idc-bldtool01 password 'new-password'
Alternatively you can run:
/usr/local/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[root bin]# ls -l /opt/mysql/mysql/data
total 0
However after this I am able to bring mysqld up:
[root libexec]# ./mysqld
InnoDB: Log scan progressed past the checkpoint lsn 0 36808
120718 8:37:22 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 43655
120718 8:37:22 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
120718 8:37:23 InnoDB: Started; log sequence number 0 43655
120718 8:37:23 [Note] ./mysqld: ready for connections.
Version: '5.0.91' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
Now I am trying to setup the root password as hinter in the above console dump:
[root~]# /usr/local/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Enter current password for root (enter for none):
Aborting!
Cleaning up...
Please let me know how can I resolve the issue?
Thanks to user868766 I managed to resolve and able to bring up mysql and connect to it.
Please try this :
1. cd /var/lib/mysql
2. adduser mysql
3. chown mysql:mysql -R /var/lib/mysql
4. service mysqld restart
Please execute the command in given order it should help you.