sudo vi /etc/mysql/my.cnf
[mysqld]
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sudo service mysql restart
sudo vi /etc/mysql/my.cnf
[mysqld]
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sudo service mysql restart
mysql_secure_installation
/var/log/mysqld.log
when trying to start MySQL:
[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
ERROR: Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory
Additionally, an exception has occurred while trying to report this error: Zend_Exception
No entry is registered for key 'translate' (Abstract.php:144)
MySQL 5.1 has been upgraded to 5.5 without running the «mysql_upgrade» command.
/etc/my.cnf
in a text editor. In this example we use the vi editor:
# vi /etc/my.cnf
2.2. Add «skip-grant-tables» on a new line under the [mysqld] section:
[mysqld]
skip-grant-tables
<…>
2.3. Save the changes and close the file.
# service mysqld start
OR
# service mysql start
# mysql_upgrade
/etc/my.cnf
file.# service mysqld restart
OR
# service mysql start
For over ways https://ruhighload.com/mysql+1045+access+denied+for+user
Your root
account, and this statement applies to any account, may only have been added with localhost access (which is recommended).
You can check this with:
SELECT host FROM mysql.userWHEREUser='root';
If you only see results with localhost
and 127.0.0.1
, you cannot connect from an external source. If you see other IP addresses, but not the one you’re connecting from — that’s also an indication.
You will need to add the IP address of each system that you want to grant access to, and then grant privileges:
CREATEUSER'root'@'ip_address' IDENTIFIED BY'some_pass';GRANTALL PRIVILEGES ON*.*TO'root'@'ip_address';
If you see %
, well then, there’s another problem altogether as that is «any remote source». If however you do want any/all systems to connect via root, use the %
wildcard to grant access:
CREATEUSER'root'@'%' IDENTIFIED BY'some_pass';GRANTALL PRIVILEGES ON*.*TO'root'@'%';
Finally, reload the permissions, and you should be able to have remote access:
FLUSH PRIVILEGES;
Following two steps worked perfectly fine for me:
Comment out the bind address from the file /etc/mysql/my.cnf
:
#bind-address = 127.0.0.1
Run following query in phpMyAdmin:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;
https://dev.mysql.com/doc/refman/5.7/en/update.html
UPDATE some_table SET field1='Value 1' WHERE primary_key = 7
UPDATE `Table A`,`Table B` SET `Table A`.`text`=concat_ws('',`Table A`.`text`,`Table B`.`B-num`," from ",`Table B`.`date`,'/')
UPDATE `table` SET `keywords` = concat_ws(', ',`keywords`,'main')
rpm -qa | grep mysql
find / -name mysql-community-libs-5.7.9-1.e17.x86_64
yum install mysql mysql-devel mysql-libs mysql-server php-mysql linode-longview perl-DBD-MySQL php-cli php-fpm php-gd php-imap php-ldap php-magickwand php-mbstring php-mcrypt php-mssql php-odbc php-pdo php-pear php-process php-shout php-snmp php-soap php-tidy php-xml php-xmlrpc php-common
PS may be problems without compat-mysql51-5.1.73-1.el6.remi.x86_64
I always forget the MySQL create database with UTF8 character set syntax, so here it is:
CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci; GRANTALLON`mydb`.*TO`username`@localhost IDENTIFIED BY 'password'; |
Alternatively, you can use ‘CREATE SCHEMA’ instead of ‘CREATE DATABASE’:
CREATESCHEMA`mydb` CHARACTER SET utf8 COLLATE utf8_general_ci; GRANTALLON`mydb`.*TO`username`@localhost IDENTIFIED BY 'password'; |
phpMyAdmin is great free web based PHP software to manage databases, tables, fields, users… and more. phpMyAdmin support MySQL, MariaDB, and Drizzle with the ability to execute SQL statements.
Unfortunately sometimes I get problem with phpMyAdmin, here is the error from phpMyAdmin on my centos Linux Server
phpMyAdmin – Error
1
|
Cannot start session without errors,please check errors given inyour PHP and/orwebserver log file andconfigure your PHP installation properly.
|
To test and find out where is session.save path
http://wiki.phpmyadmin.net/pma/session.save_path
run this script on your web server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php
// save as «session_test.php» inside your webspace
ini_set(‘display_errors’,‘On’);
error_reporting(6143);
session_start();
$sessionSavePath=ini_get(‘session.save_path’);
echo‘<br><div>’
,‘If a session could be started successfully <b>you should’
,‘ not see any Warning(s)</b>, otherwise check the path/folder’
,‘ mentioned in the warning(s) for proper access rights.<hr>’;
if(empty($sessionSavePath)){
echo‘A «<b>session.save_path</b>» is currently’,
‘ <b>not</b> set.<br>Normally «<b>’;
if(isset($_ENV['TMP'])){
echo $_ENV['TMP'],‘</b>» ($_ENV["TMP"]) ‘;
}else{
echo‘/tmp</b>» or «<b>C:tmp</b>» (or whatever’,
‘ the OS default «TMP» folder is set to)’;
}
echo‘ is used in this case.’;
}else{
echo‘The current «session.save_path» is «<b>’,
$sessionSavePath,‘</b>».’;
}
echo‘<br>Session file name: «<b>sess_’,session_id()
,‘</b>».</div><br>’;
?>
|
Here is the output i have
1
|
The current«session.save_path»is«/var/lib/php/session».
|
If the folder doesn’t exist, create one.
1
|
# mkdir /var/lib/php/session
|
You may have to change ownership of the directly
1
|
# chown user:group /var/lib/php/session
|
Or just need to change the permissions to readable and writable for the directory
1
|
# chmod 0777 /var/lib/php/session
|
Note: /var/lib/php/session ownership and permissions well reverse back to root and not writable after a reboot. It’s a good idea to run chmod and chown @reboot so you don’t have to do it manually.
add this to your crontab
1
|
# crontab -e
|
with the content (replace user:group to user/group which running apache/nginx web server)
1
2
|
@reboot chown user:group/var/lib/php/session
@reboot chmod0777/var/lib/php/session
|
CREATEUSER'username'@'localhost' IDENTIFIED BY'password';
GRANTALL PRIVILEGES ON*.*TO'username'@'localhost'WITHGRANTOPTION;
CREATEUSER'username'@'%' IDENTIFIED BY'password';
GRANTALL PRIVILEGES ON*.*TO'username'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER SCHEMA database DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
ALTER TABLE table_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE mytable CONVERTTO CHARACTER SET utf8;
show table status;
In this tutorial we will learn, how to install MySQL Server 5.6 on CentOS 7 / RHEL 7 . In our previous post, we have installed MySQL Server 5.6 on CentOS 6.x/RHEL 7.x.
In CentOS 7/ RHEL 7 , now MariaDB is introduced as a defualt database. Still many Organisations/Company would like to continue with MySQL. Whereas System Admin who earlier worked on MySQL can easily work on MariaDB. MariaDB is a community-developed fork of the MySQL relational database management system.
MariaDB’s lead developer is Michael “Monty” Widenius, the founder of MySQL and Monty Program AB. He had previously sold his company, MySQL AB, to Sun Microsystems for US$1 billion. MariaDB is named after Monty’s younger daughter, Maria. (Reference taken from Wikipedia)
Follow the given below steps to install MySQL Server 5.6 .
You must be login with root user in system
Download the rpm package, which will create a yum repo file for MySQL Server installation.
yum install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Install this downloaded rpm package by using rpm command.
rpm -ivh mysql-community-release-el7-5.noarch.rpm
After the installation of this package. We will get two new yum repo related to MySQL
[root@localhost ~]# ls -1 /etc/yum.repos.d/mysql-community* /etc/yum.repos.d/mysql-community.repo /etc/yum.repos.d/mysql-community-source.repo [root@localhost ~]#
By using yum command, now we will install MySQL Server 5.6 . All dependencies will be installed itself.
yum install mysql-server
Now MySQL Server is installed on your system.
To start MySQL Service, run command
chkconfig mysqld on
systemctl start mysqld
To stop MySQL Service, run command
systemctl stop mysqld
To restart MySQL Service, run command
systemctl restart mysqld
To get status of MySQL Service, run command
systemctl status mysqld
On fresh installation of MySQL Server. The MySQL root user password is blank.
For good security practice, we should reset the password MySQL root user.
On newly installed MySQL Server, we generally recommend to use the command script. You have to just follow the instructions.
mysql_secure_installation
In another method,you can log into MySQL server database and reset the password in secure way.
mysql -u root
You will see mysql prompt like this mysql> . Use the below given commands to reset root’s password.
mysql> use mysql; mysql> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit