I've setup MySQL on my mac a while ago and I forgot what my root password was.(there are only a few password combinations I use, and none of them seems to work) I've tried many methods, including trying to reset the root password in safe mode. Nothing seems to be working for me.
Below is the log that I got from a few solutions I tried:
1.Normal Login
Yorks-MacBook-Pro:~ yorkwang$ mysql -u root ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Yorks-MacBook-Pro:~ yorkwang$ mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (usingpassword: YES)
2.Safemode Password Reset
Yorks-MacBook-Pro:~ yorkwang$ mysqld_safe --skip-grant-tables
2016-07-08T18:37:50.6NZ mysqld_safe Logging to '/usr/local/var/mysql/Yorks-MacBook-Pro.local.err'.
2016-07-08T18:37:51.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
/usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied
rm: /tmp/mysql.sock: Permission denied
/usr/local/bin/mysqld_safe: line 169: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied
2016-07-08T18:37:51.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/Yorks-MacBook-Pro.local.pid ended
/usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied
3.Safemode Password Reset (with MYSQL server turned off)
[1]+ Stopped sudo mysqld --skip-grant-tables
Yorks-MacBook-Pro:~ yorkwang$
2016-07-08T18:43:50.807384Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-07-08T18:43:50.809064Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2016-07-08T18:43:50.810163Z 0 [Note] mysqld (mysqld 5.7.11) starting as process 68112 ...
2016-07-08T18:43:50.823374Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2016-07-08T18:43:50.835814Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-08T18:43:50.835842Z 0 [Note] InnoDB: Uses event mutexes
2016-07-08T18:43:50.835848Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2016-07-08T18:43:50.835852Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-08T18:43:50.837573Z 0 [Note] InnoDB: Number of pools: 1
2016-07-08T18:43:50.839941Z 0 [Note] InnoDB: Using CPU crc32 instructions 2016-07-08T18:43:50.850947Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-07-08T18:43:50.865025Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-07-08T18:43:50.891791Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2016-07-08T18:43:50.926530Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-07-08T18:43:50.926759Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-07-08T18:43:50.958427Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-07-08T18:43:50.959275Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-07-08T18:43:50.959287Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-07-08T18:43:50.959505Z 0 [Note] InnoDB: Waiting for purge to start
2016-07-08T18:43:51.014726Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 2494670
2016-07-08T18:43:51.015106Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2016-07-08T18:43:51.015947Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-07-08T18:43:51.029570Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2016-07-08T18:43:51.029602Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2016-07-08T18:43:51.031297Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160708 11:43:51
2016-07-08T18:43:51.033667Z 0 [Warning] CA certificate ca.pem is self signed.
2016-07-08T18:43:51.034667Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2016-07-08T18:43:51.041311Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-07-08T18:43:51.041463Z 0 [Note] IPv6 is available.
2016-07-08T18:43:51.041482Z 0 [Note] - '::' resolves to '::';
2016-07-08T18:43:51.041495Z 0 [Note] Server socket created on IP: '::'.
2016-07-08T18:43:51.149448Z 0 [Note] mysqld: ready for connections. Version: '5.7.11' socket: '/tmp/mysql.sock' port: 3306 Homebrew
mysql -u root mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Additional info: I'm using a macbook pro with OSX 10.11.5
When you are trying to start the MySQL server without the grant tables, you're receiving (multiple) Permission Denied. For instance,
/usr/local/bin/mysqld_safe: line 135: /usr/local/var/mysql/Yorks-MacBook-Pro.local.err: Permission denied
and that's why you're being unable to connect to the server (it never had the chance to start).
So, first of all, kill any mysqld_safe that might be already running (as super user):
$ sudo killall -TERM mysqld_safe; sleep 5; sudo killall -TERM mysqld
Check if the process is dead:
$ ps -ef | grep mysql
If not, and if you don't care about losing database integrity (possible data loss) issue the commands:
$ sudo killall -KILL mysqld_safe; sleep 5; sudo killall -KILL mysqld
Then, try to start the mysqld_safe with super user privileges (note the --skip-grant-tables):
$ sudo mysqld_safe --skip-grant-tables
Then connect to the MySQL Server (avoiding the use of the mysql unix socket):
$ mysql -uroot -h 127.0.0.1 --protocol=tcp
And then, under the MySQL Console:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
mysql> ALTER USER 'root'#'127.0.0.1' IDENTIFIED BY 'MyNewPass';
References:
B.5.3.2 How to Reset the Root Password
Related
I m trying to dockerize a laravel project a small problem with my MySQL Container.
I cant connect to the container my DB with root or simple user.
I only used docker-compose build && docker-compose up -d
docker exec -it ica-backoffice_attendize_db_1 /bin/bash
mysql -u root -p
Enter password: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
This is my docker log : docker logs ica-backoffice_attendize_db_1
2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-03-30 12:20:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-03-30T12:20:44.525563Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-03-30T12:20:44.527413Z 0 [Note] mysqld (mysqld 5.7.33) starting as process 1 ...
2021-03-30T12:20:44.532377Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-03-30T12:20:44.532396Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-03-30T12:20:44.532402Z 0 [Note] InnoDB: Uses event mutexes
2021-03-30T12:20:44.532407Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-03-30T12:20:44.532425Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-03-30T12:20:44.532430Z 0 [Note] InnoDB: Using Linux native AIO
2021-03-30T12:20:44.532739Z 0 [Note] InnoDB: Number of pools: 1
2021-03-30T12:20:44.532879Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-03-30T12:20:44.535236Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-03-30T12:20:44.546880Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-03-30T12:20:44.549449Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-03-30T12:20:44.561014Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2021-03-30T12:20:44.562673Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12665801
2021-03-30T12:20:44.562685Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12665810
2021-03-30T12:20:44.562690Z 0 [Note] InnoDB: Database was not shutdown normally!
2021-03-30T12:20:44.562695Z 0 [Note] InnoDB: Starting crash recovery.
2021-03-30T12:20:44.713371Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2021-03-30T12:20:44.713417Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-03-30T12:20:44.713562Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-03-30T12:20:45.454122Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-03-30T12:20:45.456067Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-03-30T12:20:45.456099Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-03-30T12:20:45.456761Z 0 [Note] InnoDB: Waiting for purge to start
2021-03-30T12:20:45.507075Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 12665810
2021-03-30T12:20:45.507543Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-03-30T12:20:45.507941Z 0 [Note] Plugin 'FEDERATED' is disabled.
2021-03-30T12:20:45.511918Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210330 12:20:45
2021-03-30T12:20:45.524384Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2021-03-30T12:20:45.524418Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2021-03-30T12:20:45.526363Z 0 [Warning] CA certificate ca.pem is self signed.
2021-03-30T12:20:45.526435Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2021-03-30T12:20:45.527538Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2021-03-30T12:20:45.527717Z 0 [Note] IPv6 is available.
2021-03-30T12:20:45.527762Z 0 [Note] - '::' resolves to '::';
2021-03-30T12:20:45.527810Z 0 [Note] Server socket created on IP: '::'.
2021-03-30T12:20:45.578895Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-03-30T12:20:45.602259Z 0 [Note] Event Scheduler: Loaded 0 events
2021-03-30T12:20:45.602848Z 0 [Note] mysqld: ready for connections.
Version: '5.7.33' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
2021-03-30T12:20:56.582691Z 2 [Note] Access denied for user 'root'#'localhost' (using password: NO)
2021-03-30T12:21:22.098439Z 3 [Note] Access denied for user 'dhia'#'localhost' (using password: YES)
2021-03-30T12:21:26.702866Z 4 [Note] Access denied for user 'root'#'localhost' (using password: NO)
2021-03-30T12:21:56.174284Z 5 [Note] Access denied for user 'root'#'localhost' (using password: YES)
.env file :
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=preprodica
DB_USERNAME=root
DB_PASSWORD=Str0ngDBP#ssw0rd
Docker compose :
services:
attendize_app:
build:
context: . # The path of the Dockerfile
volumes:
- .:/usr/src/app
depends_on:
- attendize_db
working_dir: /usr/src/app
environment:
SERVICE_NAME: attendize-app
DB_CONNECTION: mysql
DB_DRIVER: mysql
DB_HOST: attendize_db
DB_PORT: 3306
networks:
- app_network
attendize_nginx:
build:
context: ./docker-nginx/. # The path of the Dockerfile
volumes:
- "./public:/usr/src/app/public"
environment:
NGINX_FPM_HOST: attendize_app
NGINX_ROOT: /usr/src/app/public
ports:
- "8000:80"
depends_on:
- attendize_app
networks:
- app_network
attendize_db:
image: mysql:5
restart: always
environment:
MYSQL_DATABASE: "preprodica"
MYSQL_ROOT_PASSWORD: "Str0ngDBP#ssw0rd"
MYSQL_USER: "dhia"
MYSQL_PASSWORD: "dhia"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "3306:3306"
volumes:
- "./storage/db-data:/var/lib/mysql"
networks:
- app_network
networks:
app_network:
driver: bridge
Docker-compose does extra work to preserve volumes between runs (thus preserving the database); you may want to try docker-compose rm -v to delete everything and try starting it up again. The command docker-compose rm -v reflects in the containers, but NOT in the volume mapped. So, the following command will remove the containers and since it doesn't delete the volumes, the command files to create a new user.
$ docker-compose rm -v
Going to remove backendphp_qgPhpMyAdmin_1, backendphp_qgMySQLServer_1, backendphp_qgMysqlData_1
Are you sure? [yN] y
Removing backendphp_qgMysqlData_1...
Removing backendphp_qgMySQLServer_1...
Removing backendphp_qgPhpMyAdmin_1...
At this point, the only way to make it right is to delete the directory that you mapped your mysql data.
$ sudo rm -rf mysql-data
Only after that, the command created a new database with the users correctly set!
You can check this link too
https://www.programmersought.com/article/16512825562/
I Fixed using :
sudo rm -r db-data/
docker-compose up -d
docker-compose down -v
Good Luck!
I'm trying to run the MySQL Server after importing a big database file 32 GB length mismatch in the column name
MySQL 5.7 using rh-mysql57
After using the command to run the server I'm getting a success message saying
/etc/init.d/rh-mysql57-mysqld restart
Stopping rh-mysql57-mysqld: [ OK ]
Starting rh-mysql57-mysqld: [ OK ]
The i want to loggin to the mysql using mysql with/without password
i'm getting this error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
This is the error.log
2019-06-19T13:24:05.489656Z mysqld_safe Starting mysqld daemon with databases from /var/opt/rh/rh-mysql57/lib/mysql
2019-06-19T13:24:05.751511Z 0 [Note] /opt/rh/rh-mysql57/root/usr/libexec/mysqld (mysqld 5.7.24-log) starting as process 19830 ...
2019-06-19T13:24:05.816168Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-06-19T13:24:05.816207Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-06-19T13:24:05.816225Z 0 [Note] InnoDB: Uses event mutexes
2019-06-19T13:24:05.816240Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2019-06-19T13:24:05.816254Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-06-19T13:24:05.816268Z 0 [Note] InnoDB: Using Linux native AIO
2019-06-19T13:24:05.818025Z 0 [Note] InnoDB: Number of pools: 1
2019-06-19T13:24:05.818276Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2019-06-19T13:24:05.821067Z 0 [Note] InnoDB: Initializing buffer pool, total size = 2G, instances = 8, chunk size = 128M
2019-06-19T13:24:06.062258Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-06-19T13:24:06.095072Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-06-19T13:24:06.107846Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-06-19T13:24:06.275233Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-06-19T13:24:06.275514Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-06-19T13:24:06.360584Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-06-19T13:24:06.362431Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-06-19T13:24:06.362460Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-06-19T13:24:06.364052Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 322424549252
2019-06-19T13:24:06.364899Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/opt/rh/rh-mysql57/lib/mysql/ib_buffer_pool
2019-06-19T13:24:06.365282Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-06-19T13:24:06.366882Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190619 15:24:06
2019-06-19T13:24:06.381320Z 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2019-06-19T13:24:06.381431Z 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2019-06-19T13:24:06.387318Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-06-19T13:24:06.387370Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2019-06-19T13:24:06.398153Z 0 [Warning] CA certificate ca.pem is self signed.
2019-06-19T13:24:06.398250Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2019-06-19T13:24:06.399654Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-06-19T13:24:06.424466Z 0 [Note] IPv6 is not available.
2019-06-19T13:24:06.424509Z 0 [Note] - '0.0.0.0' resolves to '0.0.0.0';
2019-06-19T13:24:06.424554Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2019-06-19T13:24:06.436535Z 0 [Note] Failed to start slave threads for channel ''
2019-06-19T13:24:06.449394Z 0 [Note] Event Scheduler: Loaded 0 events
2019-06-19T13:24:06.449666Z 0 [Note] /opt/rh/rh-mysql57/root/usr/libexec/mysqld: ready for connections.
Version: '5.7.24-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
2019-06-19T13:24:07.101293Z 2 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'#'localhost' (using password: NO)
2019-06-19T13:24:36.051422Z 3 [Note] Access denied for user 'root'#'localhost' (using password: YES)
The problem as I understand is coming from here
2019-06-19T13:24:06.381320Z 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
2019-06-19T13:24:06.381431Z 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
I've tried to run mysql_upgrade and the result is
mysql_upgrade: Got error: 1045: Access denied for user 'root'#'localhost' (using password: YES) while connecting to the MySQL server
Upgrade process encountered an error and will not continue
The problem was due to an import conflict between MySQL tables from the production server and test server.
As the file was large so difficult to modify the contents of the SQL file.
So the mysql database was imported too.
CAUTION BEFORE PROCESSING PLEASE BACKUP YOUR DATABASE!
The solution that worked for us is like the rest
1- Stop the mysql server
ref: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
2-Added the following parameters to
/etc/my.cnf
ref: https://dev.mysql.com/doc/refman/5.7/en/system-schema.html
innodb_force_recovery = 1
skip-grant-tables
3- In the database directory, save the folder mysql copy themysql folder and empty the contents
4- Then execute the command
bin\mysqld --initialize
ref:
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html
5- At the end execute the command
bin\mysql_upgrade
ref: https://dev.mysql.com/doc/refman/5.7/en/mysql-upgrade.html
6- Start the mysql server again
ref: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
I got the same issue & error while working with docker.
docker exec -it container_name bash -c "mysql_upgrade -uroot -proot"
source: Running mysql_upgrade in Docker?
This started off as a root password resetting exercise- but been running into various errors: Currently stuck at conflicts on 3306 port. See last few paras of the question if you want to skip the previous steps (I just kept updating the question & title as I made progress). Thank you.
I have a mac with mysql installed- but I cant remember the password hence I've been trying to reset it using: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html (section:B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems).
While running this command:
mysqld --init-file=/home/me/mysql-init &
I got this error:
`[1] 70374
Deepaks-MacBook-Air:data root# 2018-05-06T08:35:29.269289Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T08:35:29.271535Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T08:35:29.272815Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 70374 ...
2018-05-06T08:35:29.290319Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T08:35:29.290429Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2018-05-06T08:35:29.290472Z 0 [ERROR] Aborting
2018-05-06T08:35:29.290494Z 0 [Note] Binlog end
2018-05-06T08:35:29.293896Z 0 [Note] mysqld: Shutdown complete
[1]+ Done(1)`
Hence I'm trying this command:
sudo /usr/local/mysql/support-files/mysql.server start --init-file=/usr/local/mysql/data/mysql-init
but now I'm getting this error:
ERROR! The server quit without updating PID file (/usr/local/mysql/data/Deepaks-MacBook-Air.local.pid).
The following is the content of the log file:
2018-05-06T08:03:52.799002Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T08:03:52.801385Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T08:03:52.801495Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21) starting as process 69954 ...
2018-05-06T08:03:52.810622Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2018-05-06T08:03:52.832273Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T08:03:52.832306Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T08:03:52.832313Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T08:03:52.832319Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T08:03:52.832780Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T08:03:52.833783Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T08:03:52.838027Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T08:03:52.856588Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T08:03:52.876537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T08:03:52.899436Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T08:03:52.900043Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T08:03:52.944160Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T08:03:52.946174Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T08:03:52.946218Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T08:03:52.946641Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T08:03:53.001405Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 2551377
2018-05-06T08:03:53.001712Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql-5.7.21-macos10.13-x86_64/data/ib_buffer_pool
2018-05-06T08:03:53.001962Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-06T08:03:53.019470Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-05-06T08:03:53.020660Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 13:33:53
2018-05-06T08:03:53.026724Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2018-05-06T08:03:53.026844Z 0 [Note] IPv6 is available.
2018-05-06T08:03:53.026872Z 0 [Note] - '::' resolves to '::';
2018-05-06T08:03:53.026926Z 0 [Note] Server socket created on IP: '::'.
2018-05-06T08:03:53.087999Z 0 [Note] Event Scheduler: Loaded 0 events
2018-05-06T08:03:53.088163Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.7.21' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
2018-05-06T08:12:46.664218Z 2 [Note] Access denied for user 'root'#'localhost' (using password: NO)
2018-05-06T09:35:55.013341Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 2948657ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
Whats wrong and how to fix this?
PS: I've been referring to these two SO, and am trying nearly all solutions in all answers- reseting permissions to removing all files in /usr/local/var/mysql. It still the same issue, I suspect its something to do with mysqld not running properly- is there a special way to run it as root. I'm currently trying to run in root mode in terminal by sudo -i. Can someone help me debug this? Thanks
mysql version:
> mysql --version
mysql Ver 14.14 Distrib 5.7.21, for osx10.12 (x86_64) using EditLine wrapper
UPDATE: I read the security documentation- apparently you aren't supposed to run it as root mode. So I logged out using exit.
Now, I'm getting the following situation:
Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init &
[2] 72004
Deepaks-MacBook-Air:mysql deepak$ mysqld: Can't change dir to '/usr/local/var/mysql/' (Errcode: 2 - No such file or directory)
2018-05-06T10:59:48.877152Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T10:59:48.880902Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T10:59:48.881775Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72004 ...
2018-05-06T10:59:48.897332Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
2018-05-06T10:59:48.897395Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
2018-05-06T10:59:48.897593Z 0 [ERROR] failed to set datadir to /usr/local/var/mysql/
2018-05-06T10:59:48.897607Z 0 [ERROR] Aborting
2018-05-06T10:59:48.897624Z 0 [Note] Binlog end
2018-05-06T10:59:48.899188Z 0 [Note] mysqld: Shutdown complete
which I suspect is due to the removal of my /usr/local/var/mysql directory as was suggested in one of the other answers. I'd deleted that using rm -rf. I made an new dir mkdir mysql in var and ran mysqld --init-file=/usr/local/mysql/data/mysql-init &, and it initially gives me a pid but then the logs ask me if 3306 port is already occupied:
2018-05-06T11:04:14.215705Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:04:14.218651Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:04:14.225038Z 0 [Note] Salting uuid generator variables, current_pid: 72031, server_start_time: 1525604653, bytes_sent: 0,
2018-05-06T11:04:14.225601Z 0 [Note] Generated uuid: '36553708-511d-11e8-ba65-c83fe4b8ed7b', server_start_time: 1828179975261387404, bytes_sent: 140216128435712
2018-05-06T11:04:14.225667Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 36553708-511d-11e8-ba65-c83fe4b8ed7b.
2018-05-06T11:04:14.241961Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:04:14.391057Z 0 [Note] Auto generated SSL certificates are placed in data directory.
2018-05-06T11:04:14.391874Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:04:14.490103Z 0 [Note] Auto generated RSA key files are placed in data directory.
2018-05-06T11:04:14.499147Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-05-06T11:04:14.499239Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:04:14.499424Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:04:14.499495Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2018-05-06T11:04:14.499503Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2018-05-06T11:04:14.499536Z 0 [ERROR] Aborting
I actually have two folders in my /usr/local/ - mysql and mysql-5.7.21-macos10.13-x86_64. The whole process so far, I've been running in the 'mysqlfolder and haven't really touchedmysql-5.7.21-macos10.13-x86_64`. They seem to have the same directory structure inside.
Also when I do ps aux | grep mysql, I get three processes:
Deepaks-MacBook-Air:local deepak$ ps aux | grep mysql
deepak 72071 100.0 0.0 2443044 1992 s002 S+ 4:44PM 0:00.01 grep mysql
_mysql 71985 0.0 0.2 2852472 13132 ?? Ss 4:25PM 0:00.66 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so
root 71967 0.0 0.1 2460804 7992 s002 T 4:23PM 0:00.03 sudo mysqld --init-file=/usr/local/mysql/data/mysql-init
However, when I proceed to kill the second or the third one, they simply reappear when I do ps aux again.
Also, I usually use a portforwarding to connect to a remote MySQL host. So, every once a while and in local scripts I run "ssh -fNT -L 3307:localhost:3306 -i ~/key/deepak_ubuntu_16feb.pem ubuntu#ec2-AWS-HOS-TNA-ME.compute-1.amazonaws.com"
Could this be a conflict?
UPDATE:
OK, I ignored the other directory and simply changed the port, that seemed to now avoid the conflict, but now has a different problem: mysql.sock.lock cant be accessed?
Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &
[2] 72160
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:32:45.441642Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T11:32:45.443453Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T11:32:45.444202Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72160 ...
2018-05-06T11:32:45.463651Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T11:32:45.478310Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T11:32:45.478366Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T11:32:45.478375Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T11:32:45.478384Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T11:32:45.480830Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T11:32:45.483263Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T11:32:45.487576Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T11:32:45.507092Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T11:32:45.538289Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T11:32:45.565701Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T11:32:45.565987Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T11:32:45.622322Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T11:32:45.623627Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T11:32:45.623652Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T11:32:45.623974Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T11:32:45.678385Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209980
2018-05-06T11:32:45.678936Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-05-06T11:32:45.680200Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-06T11:32:45.680346Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:02:45
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:32:45.680885Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:32:45.684081Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:32:45.686185Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-06T11:32:45.686212Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-05-06T11:32:45.691365Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:32:45.691562Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-05-06T11:32:45.693912Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
2018-05-06T11:32:45.694589Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:32:45.694853Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:32:45.695047Z 0 [ERROR] Could not open unix socket lock file /tmp/mysql.sock.lock.
2018-05-06T11:32:45.695067Z 0 [ERROR] Unable to setup unix socket lock file.
2018-05-06T11:32:45.695092Z 0 [ERROR] Aborting
OK, so I went into /tmp/ and tried to check permissions of the file- below are the results:
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock
16777220 3413029 -rw------- 1 _mysql wheel 0 6 "May 6 16:25:35 2018" "May 6 16:25:35 2018" "May 6 16:25:35 2018" "May 6 16:25:35 2018" 4096 8 0 mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
16777220 3413030 srwxrwxrwx 1 _mysql wheel 0 0 "May 6 16:25:44 2018" "May 6 16:25:44 2018" "May 6 16:25:44 2018" "May 6 16:25:35 2018" 4096 0 0 mysql.sock
I'm trying the solutions from this SO post https://stackoverflow.com/questions/34954455/mysql-daemon-lock-issue, the change owner answer did not work. I'm a little hesitant to remove locking.
OK, this post: https://support.rackspace.com/how-to/checking-linux-file-permissions-with-ls/ quite neatly explains how to read those permissions- apparently in my case _mysql user and wheel are the owner and group respectively. That doesn't make sense because I've never come across wheel in anything out side a .whl context and I haven't encountered the _mysql before today. I've tried to change to that user earlier using su - _mysql and I couldn't guess the password- not sure if mysql sets this up by default, in which case I'm confused right about now.
UPDATE:
OK, I solved that my Chowning it:
Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock
Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock
16777220 3413029 -rw------- 1 deepak wheel 0 6 "May 6 16:25:35 2018" "May 6 16:25:35 2018" "May 6 17:26:54 2018" "May 6 16:25:35 2018" 4096 8 0 mysql.sock.lock
Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
16777220 3413030 srwxrwxrwx 1 deepak wheel 0 0 "May 6 16:25:44 2018" "May 6 16:25:44 2018" "May 6 17:26:22 2018" "May 6 16:25:35 2018" 4096 0 0 mysql.sock
However, that gives rise to another error:
Can't open and lock privilege tables: Table 'mysql.user' doesn't exist.
Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &
[2] 72244
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:57:33.454182Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T11:57:33.456455Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-06T11:57:33.457505Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72244 ...
2018-05-06T11:57:33.470925Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-05-06T11:57:33.482170Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-06T11:57:33.482216Z 0 [Note] InnoDB: Uses event mutexes
2018-05-06T11:57:33.482224Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-06T11:57:33.482231Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-06T11:57:33.486263Z 0 [Note] InnoDB: Number of pools: 1
2018-05-06T11:57:33.489217Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-06T11:57:33.494624Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-06T11:57:33.513877Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-06T11:57:33.546517Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-06T11:57:33.575022Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-06T11:57:33.575404Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-06T11:57:33.620985Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-06T11:57:33.622662Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-06T11:57:33.622693Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-06T11:57:33.623068Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-06T11:57:33.677963Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209999
2018-05-06T11:57:33.679157Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-05-06T11:57:33.680426Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:27:33
2018-05-06T11:57:33.681987Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-05-06T11:57:33.684004Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-05-06T11:57:33.688066Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T11:57:33.690386Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-06T11:57:33.690502Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-05-06T11:57:33.694745Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T11:57:33.694856Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-05-06T11:57:33.695461Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
2018-05-06T11:57:33.696028Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-05-06T11:57:33.696184Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-05-06T11:57:33.700436Z 0 [Warning] Failed to open optimizer cost constant tables
2018-05-06T11:57:33.704524Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-05-06T11:57:33.704983Z 0 [ERROR] Aborting
Alright, that got resolved by changing the owner from _mysql to my normal account using chown but now the the issue is:
Deepaks-MacBook-Air:mysql deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &
[2] 72328
Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T12:21:01.547203Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:21:01.550869Z 0 [ERROR] Can't find error-message file '/usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2018-05-06T12:21:01.557694Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-05-06T12:21:01.557751Z 0 [ERROR] Aborting
Here is how I resolved this: the share folder didn't have a mysql directory and instead had the errmsg.sys in the english directory, I simply copied this file into a new directory I created in the share folder: mkdir mysql.
This worked but then showed:
Can't create directory '/usr/local/mysql/data/' (Errcode: 13 - Permission denied)
2018-05-06T12:49:13.313038Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:49:13.316262Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
2018-05-06T12:49:13.316285Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2018-05-06T12:49:13.322333Z 0 [ERROR] Aborting
Using chown, I changed the owner of mysql directory to my regular user account (strangely the mysql-5.7.21-macos10.13-x86_64 directory would not change its owner from group from root and wheel to anything even if I sudo'ed it.
So now the mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 & command from /usr/local/mysql/ shows the following output:
Deepaks-MacBook-Air:local deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &
[2] 72460
Deepaks-MacBook-Air:local deepak$ 2018-05-06T12:52:51.009693Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-06T12:52:51.013089Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
2018-05-06T12:52:51.013108Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2018-05-06T12:52:51.020232Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2018-05-06T12:52:51.549560Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-06T12:52:51.614133Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-06T12:52:51.692927Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 630bcd34-512c-11e8-934a-45e8be00c2cf.
2018-05-06T12:52:51.711501Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-06T12:52:51.847929Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-06T12:52:51.903182Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
This seemed good but nothing is happening. Is this it? Can I start connecting using my SequelPro to 'localhost:3308' now? or is there some other caveats I need to resolve like setting temp password? Before even that, do I need to go into another terminal window to try mysql -u root and leave this running or what?
Also, when I don ps aux | grep mysql it shows three processes as before but does not show 72460 the one that mysqld just showed me now. Is this something I need to be concerned about?
This is the first time I'm doing this, and I'm scared to do anything right about now to not ruin the last few hours of efforts to fix this.
How do I resolve this? Thanks!
UPDATE: FINAL ISSUES:
OK, I'm dealing with a final set of issues, gonna ask in a seperate question.
1)
Deepaks-MacBook-Air:App deepak$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
and
2)
Deepaks-MacBook-Air:App deepak$ mysqladmin -u root
mysqladmin Ver 8.42 Distrib 5.7.21, for osx10.12 on x86_64
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command....
3) In my System Preferences > MySQL, it says "MySQL server instance is STOPPED".
Firstly, the issue with running as root is that mysqld doesn't want to have root privileges. You're not wrong to run it as root though, since the data directory should by default not be writable to your own user. Simply tell it to drop privileges and run as the "mysql" user, which is the default user mysqld runs under on macOS and likely the user who owns the data directory (note that "_mysqld" and "mysql" refer to the same user on macOS for historical reasons). You do this by adding -u mysql to mysqld's command line.
The two directories should really be only one directory (with the long name that includes a version number) and one symbolic link (/usr/local/mysql pointing to the directory). That's how the MySQL installer sets things up, the symlink always points to the latest version of MySQL that was installed.
The other mysqld you see running is the one started from launchd. This is also something the MySQL installer sets up. You can use the MySQL preference pane (which should be installed by default) to shut it down. Otherwise, macOS will keep restarting it because it interprets the shutdowns as random failures. The preference pane should be somewhere at the end of the bottom row in System Preferences.
The port forwarding thing should not be an issue. It will only be active while the ssh connection is up, and it doesn't even forward the same local port.
I just updated a MySQL database from 5.5 to 5.6. I'm attempting to follow best practices so I used mysql_config_editor to create a .mylogin.cnf file:
mysql_config_editor set --login-path=local --host=localhost --user=example --password
However, when I try mysql --login-path=local I get this error:
ERROR 1045 (28000): Access denied for user 'example'#'localhost' (using password: YES)
However, I can still login using mysql -u example -p, and then pasting the password at the prompt. I've triple-checked that I'm using the correct password in my mysql_config_editor command.
My grants look like this:
mysql> show grants;
+------------------------------------------------------------------------------+
| Grants for example#localhost |
+------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'example'#'localhost' IDENTIFIED BY PASSWORD <secret> |
| GRANT ALL PRIVILEGES ON `example`.* TO 'example'#'localhost' |
+------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
This is the output to /var/log/mysql/error.log when I restart MySQL:
160223 12:31:41 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
160223 12:31:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-02-23 12:31:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-23 12:31:43 0 [Note] /usr/sbin/mysqld (mysqld 5.6.29) starting as process 31337 ...
2016-02-23 12:31:43 31337 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-02-23 12:31:43 31337 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-02-23 12:31:43 31337 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-02-23 12:31:43 31337 [Note] Plugin 'FEDERATED' is disabled.
2016-02-23 12:31:43 31337 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-02-23 12:31:43 31337 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-23 12:31:43 31337 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-23 12:31:43 31337 [Note] InnoDB: Memory barrier is not used
2016-02-23 12:31:43 31337 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-02-23 12:31:43 31337 [Note] InnoDB: Using Linux native AIO
2016-02-23 12:31:43 31337 [Note] InnoDB: Using CPU crc32 instructions
2016-02-23 12:31:43 31337 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-23 12:31:43 31337 [Note] InnoDB: Completed initialization of buffer pool
2016-02-23 12:31:43 31337 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-23 12:31:43 31337 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-23 12:31:43 31337 [Note] InnoDB: Waiting for purge to start
2016-02-23 12:31:43 31337 [Note] InnoDB: 5.6.29 started; log sequence number 1660606
SSL error: Unable to get certificate from '/etc/mysql/server-cert.pem'
2016-02-23 12:31:43 31337 [Warning] Failed to setup SSL
2016-02-23 12:31:43 31337 [Warning] SSL error: Unable to get certificate
2016-02-23 12:31:43 31337 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2016-02-23 12:31:43 31337 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2016-02-23 12:31:43 31337 [Note] Server socket created on IP: '127.0.0.1'.
2016-02-23 12:31:43 31337 [Note] Event Scheduler: Loaded 0 events
2016-02-23 12:31:43 31337 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Do you see anything in the log that might indicate why I can't login using the --login-path option?
Add double quotes to your password. It worked for me.
You should be using the socket to log in locally. Try specifying the mysql_config_editor command with the --socket=/path/to/mysqld.sock option that's correct for your MySQL instance.
I had this problem, and thought I'd share my solution in my case:
TLDR: Manually Connecting Works because the Default Host is Not Local, But You're Configuring MySQL_Config_Editor with Local
Your example of logging in omits the -h parameter: mysql -u example -p. To see what host mysql is connecting to, look at the results of: mysql --print-defaults. You get something like...
--user=ExampleUser
--password=*****
--host=host.example.com
--port=12345
The --host value you see here should exactly match what you are putting into the host value here, in order to make it work correctly:
mysql_config_editor set --host=host.example.com --user=example --password
In addition, I recommend trying without the --login-path=local, since it may actually well be that your host, according to the defaults, is not local or localhost.
According to the docs, the login-path parameter contains "options that specify which MySQL server to connect to and which account to authenticate as." (Source: Dev.MySQL.com.) So, I think your problem may be like mine: a mismatch of the right host value while also dropping --login-path=local.
MySQL (Percona 5.6) will not start.
This error has happened to me several times. Each time, I have had to remove MySQL data directories and reinstall MySQL.
Is there another way to fix MySQL? (Specifically one in which the data not blown away?)
/var/log/mysql/error.log
150214 16:36:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2015-02-14 16:36:40 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2015-02-14 16:36:40 0 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2015-02-14 16:36:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-02-14 16:36:40 1018 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2015-02-14 16:36:40 1018 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Incorrect file format 'plugin'
2015-02-14 16:36:40 1018 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2015-02-14 16:36:40 1018 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-02-14 16:36:40 1018 [Note] InnoDB: The InnoDB memory heap is disabled
2015-02-14 16:36:40 1018 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-02-14 16:36:40 1018 [Note] InnoDB: Memory barrier is not used
2015-02-14 16:36:40 1018 [Note] InnoDB: Compressed tables use zlib 1.2.8
2015-02-14 16:36:40 1018 [Note] InnoDB: Using Linux native AIO
2015-02-14 16:36:40 1018 [Note] InnoDB: Using CPU crc32 instructions
2015-02-14 16:36:40 1018 [Note] InnoDB: Initializing buffer pool, size = 256.0M
2015-02-14 16:36:40 1018 [Note] InnoDB: Completed initialization of buffer pool
2015-02-14 16:36:40 1018 [Note] InnoDB: Highest supported file format is Barracuda.
2015-02-14 16:36:40 1018 [Note] InnoDB: The log sequence numbers 714340126 and 714340126 in ibdata files do not match the log sequence number 716513090 in the ib_logfiles!
2015-02-14 16:36:40 1018 [Note] InnoDB: Database was not shutdown normally!
2015-02-14 16:36:40 1018 [Note] InnoDB: Starting crash recovery.
2015-02-14 16:36:40 1018 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-02-14 16:36:40 1018 [Note] InnoDB: Restoring possible half-written data pages
2015-02-14 16:36:40 1018 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Last MySQL binlog file position 0 292596, file name binlog.000056
2015-02-14 16:36:40 1018 [Note] InnoDB: 128 rollback segment(s) are active.
2015-02-14 16:36:40 1018 [Note] InnoDB: Waiting for purge to start
2015-02-14 16:36:40 1018 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.21-70.1 started; log sequence number 716513090
2015-02-14 16:36:40 1018 [Note] Recovering after a crash using binlog
2015-02-14 16:36:40 1018 [Note] Starting crash recovery...
2015-02-14 16:36:40 1018 [Note] Crash recovery finished.
2015-02-14 16:36:40 1018 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-02-14 16:36:40 1018 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2015-02-14 16:36:40 1018 [Note] Server hostname (bind-address): '*'; port: 3306
2015-02-14 16:36:40 1018 [Note] IPv6 is available.
2015-02-14 16:36:40 1018 [Note] - '::' resolves to '::';
2015-02-14 16:36:40 1018 [Note] Server socket created on IP: '::'.
2015-02-14 16:36:40 1018 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'
150214 16:36:40 mysqld_safe mysqld from pid file /tmp/mysqld.pid ended
I managed so solve this problem with answer from ruby.b
You'll have to repair your host table. To do this, issue the following command to start your server bypassing the privilege system
In one terminal, run
$ sudo mysqld --skip-grant-tables
Open another terminal and execute these commands
$ mysql
mysql> use mysql
mysql> repair table host use_frm;
mysql> exit
And restart the mysql service
$ sudo service mysql restart
Thanks to John for putting me on the right track, I had a few other hoops to jump through on my system. Hope this helps someone.
This is a corrupt privilege table. Maybe caused by an upgrade or power failure. My system OpenSUSE 13.2, MySQL 5.6. Simple reinstall does not fix, must delete all traces of MySQL before reinstall OR…
Close down all instances of MySQL
$ systemctl stop mysql.service
$ pkill -9 mysqld
Start server bypassing privilege system
$ sudo mysqld_safe --user=root --skip-grant-tables
Start MySQL command line tool
$ mysql
If you receive
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
mysqld_safe is running with its socket somewhere else. Find it with.
$ sudo find / -type s
Mine was in /var/run/mysql/
Edit the socket line in my.cnf, making a note of your existing socket setting.
My line became
socket=/var/run/mysql/mysql.sock
Return to 'Close down all instances of MySQL' (the top of these instructions). Follow them through to 'Start MySQL command line tool'. Hopefully you can open mysql successfully. From mysql command line.
mysql> use mysql
mysql> repair table user use_frm;
mysql> exit
Close down all instances of MySQL
$ systemctl stop mysql.service
$ pkill -9 mysqld
Re-edit my.cnf, returning the socket line to its original setting.
I had to reset permissions on 2 files in my mysql data directory.
$ chown mysql:mysql server2.err
$ chown mysql:mysql server2.pid
Start the MySQL server
$ systemctl start mysql.service
I then got the same original error with another table (db)
[ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'db'
And had to repeat the above procedure multiple times altering the 'repair' command until all privilege tables were fixed.
mysql> repair table db use_frm;
Here is the setup for #John Linhart's answer, if you're running Docker:
First, start a new docker container with the appropriate tag from the mysql-container (the same you used to write the DB with).
$ docker run --rm -it -v <named_volume>:/var/lib/mysql mysql:<tag> /bin/bash
This will launch a new container with the correct named volume (or mounted volume) mounted in the container and drop you into a shell as root. The mysqld-Daemon will refuse to launch as root though, so we'll run it as the mysql-user:
$ whoami
root
$ which mysqld
/usr/sbin/mysqld
$ su mysql
$ whoami
mysql
$ /usr/sbin/mysqld --skip-grant-tables
....
Now to run the SQL commands, we'll connect to the running container from a new terminal:
$ docker ps
CONTAINER ID [...]
abc123 [...]
$ docker exec -it abc123 /bin/bash
# We're on the container now!
$ whoami
root
$ mysql
...
And continue from there. When you're done, leave the container on the second terminal via exit. The terminal running mysqld will not respond to CMD+C, so we'll stop the container via Docker:
$ docker ps
CONTAINER ID [...]
abc123 [...]
$ docker stop abc123