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

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?

Related

What's default password in docker container mysql-server when you don't set one?

I am try to run a mysql container and connect with mysql client then:
I've used following commands:
docker run --name=mysql -d mysql/mysql-server:latest
docker exec -it mysql mysql -uroot -p
According to tutorial, the last command allow me configure database password but When I introduce the first password it fails...
The first password was root and I get an unusual error, then I try with admin, admin an even my linux user password but They don't work...
I would like to know what's the error?
There are couple of ways to see the password.
First Approach - Don't Run container in daemon mode
Check the below command
docker run --name=mysql mysql/mysql-server:latest
and this will print the password in the terminal as look at the below logs
2020-05-28T23:41:01.418347Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock'
2020-05-28T23:41:01.666070Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-28T23:41:01.714420Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/lib/mysql/mysql.sock' port: 0 MySQL Community
Server - GPL.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
[Entrypoint] GENERATED ROOT PASSWORD: PopiKQIjAS#OGj3x]yJOBLEn80p
[Entrypoint] ignoring /docker-entrypoint-initdb.d/*
2020-05-28T23:41:06.208480Z 10 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.20).
2020-05-28T23:41:07.861667Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
[Entrypoint] Server shut down
[Entrypoint] Setting root user as expired. Password will need to be changed before database can be used.
[Entrypoint] MySQL init process done. Ready for start up.
[Entrypoint] Starting MySQL 8.0.20-1.1.16
2020-05-28T23:41:08.534785Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
2020-05-28T23:41:08.549216Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-28T23:41:09.135591Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-05-28T23:41:09.369412Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-05-28T23:41:09.448584Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-28T23:41:09.500464Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Communi
ty Server - GPL.
Second Approach - Run container in daemon mode & fetch the password from logs
Check the below command to run the container
docker run -d --name=mysql mysql/mysql-server:latest
and then run the below command to fetch the password
docker logs mysql 2>&1 | grep GENERATED
Output of above command is:
[Entrypoint] GENERATED ROOT PASSWORD: PopiKQIjAS#OGj3x]yJOBLEn80p
Once you have the password by one of the above-mentioned methods, you can then login with the below command using that password
docker exec -it mysql mysql -uroot -p
When asked, enter the generated root password (see the instructions above on how to find it). Because the MYSQL_ONETIME_PASSWORD option is true by default, after you have connected a mysql client to the server, you must reset the server root password by issuing this statement:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'password';
Substitute password with the password of your choice. Once the password is reset, the server is ready for use.
Ref: https://hub.docker.com/r/mysql/mysql-server/
docker inspect <container_name_here> command output shows root password among other params
When starting a mysql container for the first time, there is no default password. The password you set while running the container is the default password that will be assigned to your root.
Starting a MySQL instance is simple:
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user and tag is the tag specifying the MySQL version you want. See the list above for relevant tags.
Following the documentation in: https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-getting-started.html
You get the password with command:
docker logs mysql 2>&1 | grep GENERATED
Example output:
GENERATED ROOT PASSWORD: Axegh3kAJyDLaRuBemecis&EShOs
There is no default password, try login in using:
sudo docker exec -it mysql mysql -u root

MySQL abort right after starting

Like described in the title, mysql stop just after starting, i searched in a lot of topics and every solutions proposed doesn't work for me...
i'm on up to date os x with a fresh install of mysql 8.0 via DMG.
my my_pc.err file in the mysql/data folder indicate this:
2020-05-20T14:43:07.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2020-05-20T14:43:07.693358Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20) starting as process 25586
2020-05-20T14:43:07.697083Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2020-05-20T14:43:07.697155Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2020-05-20T14:43:07.697233Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-20T14:43:07.697410Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
2020-05-20T14:43:07.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.pid ended
2020-05-20T14:43:17.6NZ mysqld_safe Logging to '/usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.err'.
2020-05-20T14:43:17.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
It's been now few years that i try to use mysql and never manage to make it working. I tried :
sudo /usr/local/mysql/support-files/mysql.server start, it gave me this :
Starting MySQL . ERROR! The server quit without updating PID file (/usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.pid).
i used chmod on my mysql folder.
i changed my path on bash_profile but mysql and mysqld commands is still not found.
i also tried this:
/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown
it responds this:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)'
Check that mysqld is running and that the socket: '/var/mysql/mysql.sock' exists!
ps -ef | grep mysqld gave me this information :
501 22093 549 0 6:52PM ttys004 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mysqld
/usr/local/mysql/bin/mysql -h 127.0.0.1 -P 3306 -u root -p
give this:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
my /var/mysql/mysql.sock is empty
sudo pkill mysqld
doesn't kill the process
did a fresh reinstal using https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks but when i do mysql_secure_installation i got this error:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
After few search, i found out that that i just needed to uninstall it and reinstall it with brew. Pretty sad that the dmg doesn't work but now i can use mysql properly.
Thanks a lot for the time you took to help me <3

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

Cannot start MySQL in Linux

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

I installed mysql 5.1 from the official site, but am having issues

NOTE: I am using Mac OS X Lion
Two issues in particular:
1) The server won't start when I try to start it from the pref pane
2) I get this error when I type "mysql" in the command line. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
When I type mysqld, I get the following error:
120328 17:28:55 [Warning] Can't create test file /usr/local/mysql-5.1.62-osx10.6-x86_64/data/Shaans-MacBook-Pro.lower-test
120328 17:28:55 [Warning] Can't create test file /usr/local/mysql-5.1.62-osx10.6-x86_64/data/Shaans-MacBook-Pro.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.62-osx10.6-x86_64/data/' (Errcode: 13)
120328 17:28:55 [ERROR] Aborting
120328 17:28:55 [Note] mysqld: Shutdown complete
When I type "sudo mysqld", I get the following error:
120328 17:45:48 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.1.62-osx10.6-x86_64/data/ is case insensitive
120328 17:45:48 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
120328 17:45:48 [ERROR] Aborting
120328 17:45:48 [Note] mysqld: Shutdown complete
When I type "sudo mysqld_safe", I get the following response:
120328 17:50:26 mysqld_safe Logging to '/usr/local/mysql/data/Shaans-MacBook-Pro.local.err'.
120328 17:50:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120328 17:50:32 mysqld_safe mysqld from pid file /usr/local/mysql/data/Shaans-MacBook-Pro.local.pid ended
Use mysqld to start the server - mysql starts the command line interface, not the daemon.
Depending on what distro you have, these commands may work, I use Ubuntu Server 10.04
I type:
sudo service mysql stop
sudo service mysql start
sudo service mysql restart
To perform those functions