Category Archives: MYSQL

Mysqldump error: tab (ErrCode:13-Permission denied) [How to Solve]

On the MySQL server, you can use load data infile ‘file_ name’ into table table_ name; Command to save all the data in a text file to the specified table. The most rough example is:
load data infile ‘test. TXT’ into table test_ table;
by default, load data infile has the following behavior for text:

A row corresponds to a record in the database table. The fields are separated by tab key. The value of each field is not enclosed by any characters. The row has no prefix and can be ignored

For example, a line of text:

1 test “xx”

after reading into the database, the value of the third field is “XX”, not XX

Even if the access permission of the test.txt file is changed, such as CHMOD O + R test.txt, the above problems will still occur. To solve this problem, it’s about AppArmor. This is a protection mechanism that limits each program’s access to specific directories and files. In other words, the permission of MySQL program to access this file is limited by AppArmor. For more information about AppArmor, refer to the second link (Wikipedia)
what you can really do is to give the MySQL program permission to read this file. Follow the following steps:
1) open the/etc/appliance.d/usr.sbin.mysqld file
2) at this time, you can see a lot of records about MySQL that can be read and written as directories and files, such as:

/usr/sbin/mysqld {
    #Other contents
    /var/log/mysql.log rw,
    /var/log/mysql.err rw,
 
    #Other contents
 
    #This will be your dir definition
    /tmp/ r,
    /tmp/** rw,
 
    #Other contents
}

At the end, add the corresponding permissions of the files that need to be read and written, save and exit
3) re import the AppArmor configuration, use the/etc/init.d/apparmor reload command
4) restart mysql, use the service MySQL restart command
so far, the problem should be solved. However, this may be an unsafe solution, which needs to be cautious

How to Solve MYSQL Error: mysqldump: Error 2013

Recently, I encountered mysqldump: error 2013 in mysqldump. I think it’s a common problem with parameter setting, and after adjustment, there is no effect. It turns out that oom happened. Here is a detailed description

1. Fault phenomenon

# more /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

# mysql -V           ##PXC 5.7
mysql  Ver 14.14 Distrib 5.7.20-18, for Linux (x86_64) using 6.2 # mysqldump -hlocalhost -uroot -p --port=33006 --default-character-set=utf8 -F -R -E --triggers -e \ > --single-transaction --all-databases >/tmp/alldb.sql Enter password: mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `tel_send_log` at row: 390486 The table isn't very large, and it's only about 200w rows of data. 

2. Fault analysis

At first I thought there was a problem with the relevant variable settings, so I adjusted the relevant parameters
mysql > set global connect_timeout=1800;
mysql > set global net_read_timeout=1800;
mysql > set global net_write_timeout=1800; mysql > set global max_allowed_packet=1024*1024*1024; mysql > set global net_ buffer_length=1024*1024; After exporting again, the problem remained, and after the error was reported, mysqld just hung up Checking mysqld's error log also did not get the specific information about the error, and thought it was too new version encountered bugs later added an option - skip-extended- insert (this is not enabled mysql generate insert contains multiple values) also does not work after switching to another node, the export is normal. So I opened the error system log message and saw thatout of memory # tail -fn 50 /var/log/message Apr 26 15:13:10 zcd kernel: Out of memory: Kill process 10274 (firewalld) score 5 or sacrifice child Apr 26 15:13:10 zcd kernel: Killed process 10274 (firewalld) total-vm:333984kB, anon-rss:21980kB, file-rss:44kB, shmem-rss:0kB Apr 26 15:13:10 zcd systemd: firewalld.service: main process exited, code=killed, status=9/KILL Apr 26 15:13:10 zcd mysqld_safe: /usr/bin/mysqld_safe: line 220: 9658 Killed nohup /usr/sbin/mysqld --basedir=/usr --datadir=/u02/pxcdata --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --wsrep-provider=/usr/lib64/galera3/libgalera_smm.so --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=33006 --wsrep_start_position=e12b32d1-06f1-11e8-b907-d7b0846b449d:68722 < /dev/null > /dev/null 2>&1 Apr 26 15:13:10 zcd mysqld_safe: 2018-04-26T07:13:10.742581Z mysqld_safe Number of processes running now: 0 Apr 26 15:13:10 zcd mysqld_safe: 2018-04-26T07:13:10.831232Z mysqld_safe WSREP: not restarting wsrep node automatically Apr 26 15:13:10 zcd mysqld_safe: 2018-04-26T07:13:10.835441Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended So restart mysql, then export again and observe the memory usage, as follows, you can see that the free column value is decreasing procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 1 0 625288 31836 1347284 0 0 19840 372 3181 3394 9 3 42 46 0 0 1 0 586820 31844 1365304 0 0 19840 60 2385 3264 7 3 46 44 0 0 1 0 515076 31956 1400024 0 0 19312 564 2681 3327 7 4 43 46 0 0 1 0 478708 31964 1417948 0 0 20368 24 3057 3301 8 4 43 46 0 0 1 0 400960 31964 1452688 0 0 19840 0 2213 3278 7 3 44 47 0 0 1 0 364868 31964 1468268 0 0 19840 24648 3053 3500 7 4 40 50 0 0 2 0 324640 31976 1488112 0 0 4544 43656 1079 1688 2 2 14 83 0 0 1 0 286768 32116 1505272 0 0 19840 760 3412 3877 7 5 25 64 0 0 1 0 248916 32132 1520528 0 0 19840 36 4065 5746 13 4 43 41 0 0 1 0 

Mysqldump: command not found [How to Solve]

First of all, you must know the full path of the mysql command or mysqldump command. You can use the find command to find it.
Unless you know the mysql installation path, you can skip this step.

find / -name mysql -print

For example, the path of my mysql is: /usr/local/mysql/bin/mysql, and then map a link to the /usr/bin directory, which is equivalent to creating a link file

ln -fs /usr/local/mysql/bin/mysql /usr/bin

mysqldump is the same, where /usr/local/mysql/ is the installation path of mysql.

 

 

 

Solution to the error of MySQL: unrecognized service (CentOS)

service mysql start Error, mysql won’t start, the solution for mysql: unrecognized service error is as follows.

[[email protected] ~]# service mysql start
mysql: unrecognized service
[[email protected] ~]# service mysql restart
mysql: unrecognized service

[[email protected] ~]# rpm -q mysql The query found that mysql is installed properly
mysql-5.1.52-jason.1

[[email protected] ~]# /etc/rc.d/init.d/mysqld start Start directly with no problem
Starting mysqld: [ OK ]

[[email protected] ~]# ls /etc/rc.d/init.d/mysqld -l
-rwxr-xr-x 1 root root 5509 Dec 18 02:31 /etc/rc.d/init.d/mysqld

[[email protected] ~]# chkconfig mysqld on Set mysql to start on boot

[[email protected] ~]# chmod 755 /etc/rc.d/init.d/mysqld Modify mysqld execute permissions

[[email protected] ~]# service mysqld start Get it done
Starting mysqld: [ OK ]
[[email protected] ~]# service mysqld start
Starting mysqld: [ OK ]
[[email protected] ~]# service mysqld status
mysqld (pid 9487) is running…

If the above does not work, you can also refer to this.

Solution to connect to Mysql prompting Can’t connect to local MySQL server through socket

The main change is: my.cnf file [mysql socket file location is set in /etc/my.cnf]

[mysqld]
datadir=/storage/db/mysql
socket=/storage/db/mysql/mysql.sock
 
[mysql]
socket=/storage/db/mysql/mysql.sock
 
[mysqldump]
socket=/storage/db/mysql/mysql.sock
 
[mysqladmin]
socket=/storage/db/mysql/mysql.sock

I modified this problem first and implemented it according to the first method

attachment: modify MySQL default password (default is empty)

Modify MySQL default account password

After installing the MySQL database, you must modify the default account password of the database to ensure the security of the database

#mysql

mysql> usemysql;

Databasechanged

mysql> selectuser,password,hostfromuser;

+——-+——————————————-+—————–+

|user|password|host|

+——-+——————————————-+—————–+

|root||localhost|

|root||email-admin|

|root||127.0.0.1|

|root||::1|

localhost|

email-admin|

|root||%|

Check the database and find that the default root account and empty account are not set up password

Change the password for the root user

mysql>updateusersetpassword=PASSWORD(‘yourpassword’) whereuser=’root’;

QueryOK,5rowsaffected(0.00sec)

Rowsmatched:5Changed:5Warnings:0

Delete empty account

mysql>deletefromuserwhereuser=”;

QueryOK,2rowsaffected(0.00sec)

mysql>selectuser,password,hostfromuser;

+——-+——————————————-+—————–+

|user|password|host|

+——-+——————————————-+—————–+

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|localhost|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|email-admin|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|127.0.0.1|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|::1|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|%|

Finally, refresh the cache to ensure that the new password is immediately available

mysql>flush privileges;

QueryOK,0rowsaffected(0.01sec)

 

How to Solve MYSQL Error: Can’t create test file xxx lower-test

In Linux, the prompt MySQL prompts [warning] cant create test file XXX lower test. Here are some friends who have encountered this kind of problem. Let’s have a look at the solution

I think you must have come in from the search engine! You must want to change the default installation of MySQL data directory
you have modified the value of dataDir in my.cnf

The first is to look at the database log

mysqld started

[Warning] Can’t create test file xxx.lower-test
[Warning] Can’t create test file xxx.lower-test
/usr/libexec/mysqld: Can’t change dir to ‘/xxx’ (Errcode: 13)
[ERROR] Aborting

You’ve chown and Chmod several times about the owner and permission of the new data directory or its parent path

You’ve tried to service mysql start, or/etc/init.d/mysql start, or mysql start countless times_ install_ db!

Congratulations on reading this article. I found a solution after being trapped by the system for several hours

There are two reasons for this. Any one of them will cause you to be told the warning by the system. If you are not a professional Linux system security engineer, or if you are just a php programmer, and do not have in-depth research on system security, you will not be easy to find the answer

First, SELinux. I remember when I was a student, RedHat was installed on the character interface There is such an option, usually we listen to the advice of the predecessors, change the default value to not install it. But if the machine you are about to operate is running SELinux, it can really prevent your MySQL from running in the new target location_ install_ DB operation, and the title of the warning. A simple solution is to use the command to shut down SELinux temporarily so that your operation can continue
setenforce 0

But it’s best to use a permanent method so that you don’t want the goods after restart

Modify SELinux = disabled in/etc/SELinux/config file, and then restart or wait for the next restart

Second, AppArmor, which is the same as SELinux, also limits the directory permissions that MySQL can use
in the file/etc/apparmor.d/usr.sbin.mysqld, there are two lines that specify the data file path permissions that MySQL can use

/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

As you can see,/var/lib/MySQL/is the default path of the data files installed in MySQL before, and the permission of the directory where mysqld can be used is controlled by the app
I want to move the data files to/data/MySQL, so that mysqld can use the directory/data/MySQL, just follow the above two and add the following two

/data/mysql/ r,
/data/mysql/** rwk,

Restart the application,/etc/inid.d/application restart

 

MYSQL ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

When I’m ready to authorize users:

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

In the following situation o (╥﹏╥) O:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> show variables liek "%validate%"

When I still can’t resist my enthusiasm of learning and struggling, After a while, we found the key to the problem

The original reason is the default security level of MySQL

Next, let’s look at the default security level of MySQL

mysql> show variables like "%validate%";

The length of the original MySQL password is 8 bits, and the password principle is medium

We found this problem, and we started to solve it

(1) In ordinary learning and training, we can set its length to 4 digits

mysql> set global validate_password_length=4;

(2) Set its security policy as: low

mysql> set global validate_password_policy=0;

Ha ha! Next, we can check the password security information of MySQL

mysql> show variables like "%validate%";

Now we can reauthorize~

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.03 sec)

I hope the above methods are useful to you, there is no bug problem in life.

[Solved] MySQL uses the workbench tool, and the table status is read only

Solution:

If the primary key is not set in the database table in MySQL, you cannot edit the data directly in the workbench, you must set PK and NN.

Expansion:

– PK: primary key (column is part of a pk)

– NN: not null (column is nullable)

– UQ: unique (column is part of a unique key)

– AI: auto increment (the column is auto incremented when rows are inserted)

– BIN: binary (if dt is a blob or similar, this indicates that is binary data, rather than text)

– UN: unsigned (for integer types, see docs: “10.2. Numeric Types”)

– ZF: zero fill (rather a display related flag, see docs: “10.2. Numeric Types”)

oracle No more data to read from socket ora-07445 [How to Solve]

This afternoon, a colleague from the original department came over and said that there was an environment that was about to go online. Occasionally, there was no more data to read from socket error. The version was Oracle 11.2.0.1, as follows:

After investigation, there are many reasons for this problem, including Oracle’s own bugs, possible configuration problems, and possible code problems. The main problems are as follows:

1. The minimum size of JDBC connection pool is 10, and the maximum size is 100. We can check the validity of the pool. This reason can be eliminated

2. It may be the cause of insufficient memory. Check the SAR history to eliminate this cause

3. It is possible to bind variable peeping problem, which can be set_ optim_ peek_ user_ Bind = false

Above reference: https://stackoverflow.com/questions/7839907/no-more-data-to-read-from-socket-error

For such problems, Oracle alert and trace are the first ones to be checked. According to the development feedback period, there are many dumps

There are the following types of ora-07445 in total

ORA-07445: exception encountered: core dump [pfr_ v3_ tab_ handler()+311] [SIGSEGV]

Bug10269022, executing a PL/SQL block dynamically that returns a ref cursor failures with ora-7445 [PFR]_ v3_ tab_ Handler] – superceded, 11.2.0.3

Ora-07445: exception occurred: core dump [ksuklms() + 316]

Confirmed bug 13322802, 11.2.0.4 fix

ORA-07445: exception encountered: core dump [dbgrmqmqpk_ query_ pick_ key()+2033]

Confirmed bug 9390347, 11.2.0.2 fix

ORA-07445: exception encountered: core dump [kocgpn2()+141] [SIGSEGV]

This error number does not find the corresponding bug record

Finally, let users upgrade to 11.2.0.4

In addition, it may be caused by the complexity of SQL. For example, if there is a with clause in SQL, and with refers to another with, it may also be solved after flattening

Oracle SQL Developer Warning: enter the full pathname for java.exe

 

Prompt for using Oracle SQL developer for the first time: enter the full pathname for java.exe

Oracle SQL developer prompt: enter the full pathname for java.exe

This java.exe is in your Oracle11g installation directory, for example: F: app, Chen, product, 11.2.0, dbhome_ Java.exe under [JDK/JRE/bin]. It’s not java.exe under javajdk installed on your computer
note that the first time you use sqldeveloper, you will be prompted to specify the path of java.exe. Do not specify your own Java_ I just don’t know at the beginning. I specify a JDK6 and say it’s not compatible at the end You can use the JDK path under the Oracle installation path, as shown in the figure:

Of course, if you are not careful, the choice is wrong. Java was chosen_ The advanced version of home is not compatible after opening sqldeveloper and reporting an error. There are also solutions. It can be found in
[F: (APP, Chen, product, 11.2.0, dbhome]_ 1. Find the [sqldeveloper. Conf] file in the path of [sqldeveloper/sqldeveloper/bin] and open it
to find the matching value of setjavahome and delete the following configuration content. The system will prompt that the read-only file cannot be saved. At this time, you can save it to the desktop, and then go back to the bin directory to delete the file, and then copy the file on the desktop. When you open it again, select java.exe again. Just choose the right one