After MySQL was introduced into AWS Lightsail, I tried to log in to MySQL first, but I received the following error:
Enter current password for root (enter for none):
ERROR 2002(HY000): Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(2)
Unable to connect to the server as root user, giving up.
Cleaning up...
I made it because mysql.sock is missing.
$sudo touch/var/lib/mysql/mysql.sock
This time, the error number will be changed and there will be no permission.
$mysql-u root
ERROR 2002(HY000): Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(13)
So I'll give you permission.
$sudo chmod777/var/lib/mysql/mysql.sock
This time, you will receive an error saying that you cannot connect to the server further.
$mysql-u root
: Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock' (111)
At the same time, you are prompted to delete the file /var/lib/mysql/mysql.sock that you created first.
$sudo service mysqld start
Socket file /var/lib/mysql/mysql.sock exists.
The file/var/lib/mysql/mysql.sock is not a socket file, which is suspicious.
Please, remove/var/lib/mysql/mysql.sock manually to start the service.
Delete it.
$sudorm/var/lib/mysql/mysql.sock
This will return to the starting point.
ERROR2002(HY000): Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(2)
The my.cnf file contains:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links = 0
character-set-server=utf8
innodb_buffer_pool_size=256M
[client]
socket=/var/lib/mysql/mysql.sock
port = 3306
[mysqld_safe]
log-error=/var/log/mysqld.log
The log looks like this.
2020-08-230 09:25:26 4206 [Note] Plugin'FEDERATED' is disabled.
^G/usr/libexec/mysql56/mysqld: Can't find file:'./mysql/plugin.frm' (errno:13-Permission denied)
2020-08-230 09:25:26 4206 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-08-230 09:25:26 4206 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-08-230 09:25:26 4206 [Note] InnoDB: The InnoDB memory heap is disabled
2020-08-230 09:25:26 4206 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builds
2020-08-230 09:25:26 4206 [Note] InnoDB: Memory barrier is not used
2020-08-2309:25:26 4206 [Note] InnoDB: Compressed tables use zlib 1.2.8
2020-08-230 09:25:26 4206 [Note] InnoDB: Using Linux native AIO
2020-08-230 09:25:27 4206 [Note] InnoDB: Using CPU crc32 instructions
2020-08-2309:25:27 4206 [Note] InnoDB: Initializing buffer pool, size=256.0M
2020-08-230 09:25:27 4206 [Note] InnoDB: Completed initialization of buffer pool
2020-08-230 09:25:27 4206 [ERROR] InnoDB:./ibdata1 can't be opened in read-write mode
2020-08-230 09:25:27 4206 [ERROR] InnoDB: The system tablespace must be writable!
2020-08-230 09:25:27 4206 [ERROR] Plugin'InnoDB' init function returned error.
2020-08-230 09:25:27 4206 [ERROR] Plugin'InnoDB' registration as a STORAGE ENGINE failed.
2020-08-230 09:25:27 4206 [ERROR] Unknown/unsupported storage engine:InnoDB
2020-08-230 09:25:27 4206 [ERROR] Aborting
Do you understand the difference between the mysql
command and the mysqld
command? It only looks like I'm doing something useless
mysqld
Specifications that create a socket where mysqld
is /var/lib/mysql/mysql.sock
when the MySQL daemon body starts.The mysql
command then attempts to connect to this socket.So if you create sudo touch/var/lib/mysql/mysql.sock
and other normal files, naturally the connection to the socket will fail, resulting in an error.Therefore, it is natural for me to ask you to delete the file.
Cannot connect to mysql.sock
=mysql.sock
socket not generated by mysqld
=mysqld
failed to start, so what you should see now is log-error=/var/log/mysqld.log
.
You had another question.The log has been reprinted, so I'll read it.The fatal wound is
2020-08-2309:25:27 4206 [ERROR] InnoDB:./ibdata1 can't be opened in read-write mode
InnoDB:./ibdata1 cannot be opened in readable mode.
Now that I'm delusional about the reason,
mysql
Missing/Disabled/Permission Settings BadMYSQL_DATADIR
is missing/configuration is badMYSQL_DATADIR
The ibdata1
file is missingMYSQL_DATADIR
does not have read/write permission for user/groupmysqlibdata1
file does not have read/write permission for user/groupmysqlMYSQL_DATADIR
ibdata1
is corrupted due to insufficient capacity, etc.If you're just delusional, you can spread it out, but only the questioner knows the truth.
Our hpux server contains the old mysql
and specifies MYSQL_DATADIR=/home/mysql/data
.
#cd/home/mysql/data
# ls-libdata1
-rw-rw ----1 mysql mysql 45651584 Aug 5 16:38 ibdata1
#
The user mysql
group mysql
has ibdata1
readable and correctly started mysqld
as shown in .
© 2024 OneMinuteCode. All rights reserved.