Crmgo Blog

MYSQL

← Blog / Linux

MYSQL

Posts: 12

MySQL Cheat Sheet

MySQL Cheat Sheet

· MYSQL

Settings List of configuration parameters and their values User Management List of users List of privileges for user root@localhost Creating a new user Add selected privileges for all tables in the dbname database to user 'user'@'localhost' Add all privileges for all tables in the dbname database to user 'user'@'localhost' Deleting...

MySQL recovery after failures.

MySQL recovery after failures.

· MYSQL

If MySQL fails to start: vim /etc/my.conf [mysqld] innodb_force_recovery = 1 service mysql start Dump all data: mysqldump database | gzip > database.sql.gz Check integrity: mysqlcheck --auto-repair --all-databases -p Below are possible options for mysqlcheck. Which of them are supported…

MySQL: Identifying Long-Running Queries

MySQL: Identifying Long-Running Queries

· MYSQL

[mysqld] long_query_time=1 log-slow-queries=/var/log/mysql/log-slow-queries.log long_query_time = 10 mkdir /var/log/mysql touch /var/log/mysql/log-slow-queries.log chown mysql.mysql -R /var/log/mysql

MySQL Replication Master - Slave

MySQL Replication Master - Slave

· MYSQL

Step 1. Configuring the Master mkdir /var/log/mysql/ touch /var/log/mysql/mysql-bin.log chown -R mysql:mysql /var/log/mysql/ On the server that will act as the master, you need to make changes to my.cnf: Restart MySQL: Step 2. Replication Permissions Next, you need to create a user profile from which the…

Resetting MySQL Password

Resetting MySQL Password

· MYSQL

service mysqld stop mysqld_safe --skip-grant-tables mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit service mysqld start

mysql show status

mysql show status

· MYSQL

The above status variables have the following values: Variable Value Aborted_clients The number of connections that were aborted because the client disconnected without properly closing the connection. See section A.2.9 Communication Errors / Aborted Connections. Aborted_connects The number of failed attempts to connect to the MySQL server. See section…

MySQL String Operations

MySQL String Operations

· MYSQL

Working with ASCII(str string) BIN(int integer) CHAR(int integer, ...) CHARACTER_LENGTH(str string) CHAR_LENGTH(str string) CONCAT(str1 string, str2 string, ...) CONCAT_WS(separator string, str1 string, str2 string, ...) CONV(int_or_str integer or string, from_base...

MySQL, replication issues.

MySQL, replication issues.

· MYSQL

When using MySQL Master-Slave (or Master-Master) replication, there may be situations where, for various reasons, the slave's version is lower than the master's version. If the binlog_format=MIXED option is used in such cases, it may result in the master writing a record to its binlog in the following format: BINLOG 'XMawShMEAAAARwAAAEp5UwUAAGkAAAAAAAAACHNhblahblahblah'…

MYSQL: Frequently Used Commands

MYSQL: Frequently Used Commands

· MYSQL

Create a user: GRANT ALL PRIVILEGES ON *.* TO user@"%" IDENTIFIED BY 'pass' WITH GRANT OPTION; Create a password, change password: set password for user = password(' newpassword '); Create a string column namepc with a length of 20 characters in the clients table ALTER TABLE `clients`…

MySQL Replication

MySQL Replication

· MYSQL

Master Settings Be sure to specify a unique server ID, the path for binary logs, and the database name for replication in the [mysqld] section: server-id = 1 log-bin = /var/lib/mysql/mysql-bin replicate-do-db = testdb Make sure you have enough disk space for binary logs. Let's add...