Cannot start MySQL in Linux - mysql

Have downloaded MySQL repository through the APT repository, then already did sudo apt-get update and sudo apt-get install mysql-server. But I got the error below:
asus#asus-K40IJ:~$ sudo mysqld
[sudo] password for asus:
2018-11-10T04:34:58.070075Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-10T04:34:58.074324Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 3686 ...
2018-11-10T04:34:58.077869Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2018-11-10T04:34:58.077928Z 0 [ERROR] Aborting
2018-11-10T04:34:58.077959Z 0 [Note] Binlog end
2018-11-10T04:34:58.078047Z 0 [Note] mysqld: Shutdown complete
Why is this and how to solve this..?

It is not recommended to run 'mysqld' as root for security. But you can do it with '--user=root' option.
Please see for more details.
https://dev.mysql.com/doc/refman/8.0/en/security-against-attack.html

Related

MySQL 8 on Ubuntu 22.04 stuck in upgrade loop error

MySQL will not start on my Ubuntu 22.04 LTS server. It was working for a few months but then got caught in the following loop that appears to be due to a server upgrade it tries to run when it starts:
2022-11-04T18:40:51.568052Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 8978
2022-11-04T18:40:51.581277Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-11-04T18:41:59.849028Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-11-04T18:42:03.102797Z 4 [System] [MY-013381] [Server] Server upgrade from '80030' to '80031' started.
2022-11-04T18:42:54.565027Z 4 [ERROR] [MY-013178] [Server] Execution of server-side SQL statement 'EXECUTE stmt; ' failed with error code = 1091, error message = 'Can't DROP 'PRIMARY'; check that column/key exists'.|
2022-11-04T18:42:54.569286Z 0 [ERROR] [MY-013380] [Server] Failed to upgrade server.
2022-11-04T18:42:54.569392Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-04T18:42:55.869863Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.22.04.1) (Ubuntu).
My logs are just repeats of those lines over and over again.
From the logs, I am guessing the upgrade script is trying to run a query that requires DROP PRIMARY but I can't find that query.
I have tried rebooting the server and restarting with systemctl. Neither changed the behavior.
I have tried to uninstall mysql-server from the command line but it says that it is only partially installed and then tries to install and run it generating the same errors as above.
When I try to kill it, it just respawns seconds later.
How can I fix this error loop?
I tried re-installing mysql-server but it did not work. I needed to disable mysql, uninstall it, purge it, clear the configs, and THEN reinstall.
I was able to stop the error loop with the following code:
sudo systemctl stop mysql
sudo systemctl disable mysql
sudo apt remove --purge mysql*
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo apt-get install mysql-server
The disable was key to stopping the loop and the rm from the etc folders did not cause an error on install.
This was found through combining https://subscription.packtpub.com/book/big-data-and-business-intelligence/9781788395809/1/ch01lvl1sec16/uninstalling-mysql-8 and https://www.digitalocean.com/community/questions/completely-uninstall-mysql-server

Keyring mirgration failure Fedora mySql

I've been working through MySQL but I've been having trouble entering my MySQL server to change certain properties. When I attempt to enter as root I get the following output:
//]$ sudo mysqld -u root -p
Enter password:
mysqld: Can not perform keyring migration : Invalid --keyring-migration-source option.
2020-02-12T05:34:59.837715Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 64421
2020-02-12T05:34:59.839462Z 0 [ERROR] [MY-011084] [Server] Keyring migration failed.
2020-02-12T05:34:59.839481Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-02-12T05:34:59.839559Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
Can't figure out how to sort this out. Any help would be much appreciated.
keyring-migration-source exists in one of the configuration files.
mysqld --help --verbose will list which files are read at the top. Look in those and remove the line.
Also don't run mysqld as root. Its a security hazard and won't start. Use the systemctl start mysql that fedora provides.

Unable to reset MySQL Server Root Password

I tried to start MYSQL in safe mode to reset the root password, but getting the below error.
I had mysql server installed on my mac, yesterday i encountered some error where it was repeatedly shutting down automatically. However i wasn't able to connect to server using command line as it was erroring out mentioning the root password was wrong. Though I was able to connect using mysql workbench.
I reinstalled SQL Server and still not able to login using the new root password.
sudo mysqld --skip-grant-tables
2019-10-23T10:13:40.361911Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-23T10:13:40.362146Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-10-23T10:13:40.362217Z 0 [Note] mysqld (mysqld 5.7.28) starting as process 4763 ...
2019-10-23T10:13:40.365571Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.7.28-macos10.14-x86_64/data/ is case insensitive
2019-10-23T10:13:40.365648Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2019-10-23T10:13:40.365676Z 0 [ERROR] Aborting
2019-10-23T10:13:40.365690Z 0 [Note] Binlog end
2019-10-23T10:13:40.365844Z 0 [Note] mysqld: Shutdown complete

Can't start sudo mysqld with --skip-grant-tables

I am looking at these instructions to reset the mysql root password on an Ubuntu development machine.
#> sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
Seems to work but then
#> sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
2016-09-04 15:27:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-09-04 15:27:13 0 [Note] /usr/sbin/mysqld (mysqld 5.6.31-0ubuntu0.15.10.1) starting as process 8892 ...
This process exits. Afterwards, when I try
#> mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
What's going wrong?

CentOS Can't get MySQL started when trying to updated from MySQL 5.1 to 5.5

I've waded through forum post after forum post. I can't figure this out. I'm using CentOS 6.5, which had MySQL 5.1, but I need 5.5! I've been looking at a lot of posts but the main one I've been using as my go to manual is this one. I've attached a step by step of what I have done and their results. I
can tell that I have 5.5, but I can't get it to start.
[informatics#aib-bitest ~]$ sudo /sbin/service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]
## Tried to restart [root#aib-bitest log]# service mysqld restart Stopping mysqld: [ OK ] MySQL Daemon failed to start. Starting mysqld: [FAILED]
## Tried to update [root#aib-bitest log]# mysql_upgrade Looking for 'mysql' as: mysql Looking for 'mysqlcheck' as: mysqlcheck FATAL ERROR: Upgrade failed
## Realized that mysqld is not running [root#aib-bitest log]# service mysqld status mysqld is stopped
## And then Realized that I couldn't get it running. [root#aib-bitest log]# service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]
## Just tested this just because [root#aib-bitest log]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
## Changed access rights [root#aib-bitest log]# chown -R mysql:mysql /var/lib/mysql [root#aib-bitest log]# service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]
## Restarted Apache [root#aib-bitest log]# sudo service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [root#aib-bitest log]# service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]
[root#aib-bitest log]# mysql_install_db Installing MySQL system tables... 150417 10:06:12 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release. 150417 10:06:12 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys' 150417 10:06:12 [ERROR] Aborting
150417 10:06:12 [Note]
Installation of system tables failed! Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
shell> /usr/libexec/mysqld --skip-grant &
and use the command line tool /usr/bin/mysql to connect to the mysql database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log gives you a log in /var/lib/mysql that may be helpful.
Please consult the MySQL manual section 'Problems running mysql_install_db', and the manual section that describes problems on your OS. Another information source are the MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before submitting a bug report at http://bugs.mysql.com/
#--------------------------------------------------------------------------------------------
[root#aib-bitest log]# /usr/libexec/mysqld --skip-grant 150417 10:07:30 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release. 150417 10:07:30 [Warning] Using unique option prefix skip-grant instead of skip-grant-tables is deprecated and will be removed in a future release. Please use the full name instead. 150417 10:07:30 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys' 150417 10:07:30 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
150417 10:07:30 [ERROR] Aborting
150417 10:07:30 [Note]
#--------------------------------------------------------------------------------------------
[root#aib-bitest log]# /usr/libexec/mysqld --skip-grant-tables 150417 10:08:20 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release. 150417 10:08:20 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys' 150417 10:08:20 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
150417 10:08:20 [ERROR] Aborting
150417 10:08:20 [Note]
#--------------------------------------------------------------------------------------------
## Added user = mysql to /etc/my.cnf [root#aib-bitest log]# nano /etc/my.cnf
## Tried this again [root#aib-bitest log]# /usr/libexec/mysqld --skip-grant-tables 150417 10:35:38 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release. 150417 10:35:38 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys' 150417 10:35:38 [Note] Plugin 'FEDERATED' is disabled. 150417 10:35:38 InnoDB: The InnoDB memory heap is disabled 150417 10:35:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins 150417 10:35:38 InnoDB: Compressed tables use zlib 1.2.3
150417 10:35:38 InnoDB: Using Linux native AIO 150417 10:35:38 InnoDB: Initializing buffer pool, size = 128.0M 150417 10:35:38 InnoDB: Completed initialization of buffer pool 150417 10:35:38 InnoDB: highest supported file format is Barracuda. 150417 10:35:38 InnoDB: Waiting for the background threads to start 150417 10:35:39 InnoDB: 5.5.40 started; log sequence number 1595675 150417 10:35:39 [ERROR] Aborting
150417 10:35:39 InnoDB: Starting shutdown... 150417 10:35:40 InnoDB: Shutdown completed; log sequence number 1595675 150417 10:35:40 [Note]
#--------------------------------------------------------------------------------------------
[root#aib-bitest log]# /sbin/service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]