I want to change max_allowed_packet on server using WHM vps.
but I am not getting at where it located, so please help me
I have tried
SET GLOBAL max_allowed_packet =1073741824;
but its not working its required super admin.
how to edit mysql.ini in WHM vps
same with httpd.conf, how to edit setting of apache in WHM ?
Ahoy,
You can not edit the servers my.cnf file from inside WHM, you will need to edit this file using she ssh command line. To learn how to connect to your server using ssh please see:
http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/ShellAccess
Once you are connected to your server with the root login using ssh, you will want to issue the following command to edit my.cnf:
# nano -w /etc/my.cnf
In this file you will want to add a line under the [mysqld] section with the following contents:
max_allowed_packet=500M
You will now want to press Ctrl + O to save, and then Ctrl + X to exit. You will now want to restart the MySQL server through WHM or on the command line with:
# /etc/init.d/mysql restart
This will update the max_allowed_packet for cPanel/WHM's mysql.
Change in the my.ini/my.cnf file. Include the single line under [mysqld] in your file
max_allowed_packet=500M
now restart the MySQL service once you are done. You can see it's current value in mysql like this:
SHOW VARIABLES LIKE 'max_allowed_packet'
You can read about it here http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html
Related
I am running an Xubuntu 16.04 machine, and have installed mysql version 5.6. I wanted to change the mysql settings buffer pool size among other things. I tried editing /etc/mysql/my.cnf, /etc/mysql/conf.d/mysql.cnf. Then restarted mysql server. After that, when I login to mysql console and try to print the variables, I still do not see the values I entered in the config files. What am I missing?
EDIT
I have put the settings under [mysqld] section. Below is the content of the above files:
[mysqld]
innodb_buffer_pool_size=4G
innodb_log_buffer_size=512M
innodb_log_file_size=2G
innodb_write_io_threads=16
innodb_flush_log_at_trx_commit=0
i'm working on server with centOS and i'm trying to import database from another server. While importing from file in phpmyadmin I'm reciving #2006 error 'server has gone'
From the information I found, i need to change max_allowed_packet but the thing is needed to add this line in /etc/my.cnf beacuse this file wasn't have any variables. I cannot find another my.cnf ( tried find /name my.cnf ) but it given me only this file, but when i type show variables in phpmyadmin - i've got plenty of vars with max_allowed_packet at 1mb.
i located my.cnf in /etc/my.cnf and /etc/my.cnf.d/server.cnf and there was no line like max_allowed_packet - so i added it, restarted with service mariadb restart and still this value got 1MB value
what can i do?
Solution which worked for me was log with ssh to mysql and there run sql script " set global max_allowed_packet " to 3344558823 . restart db by "services mariadb restart"
I want to change the default port number of MySQL server presently it is 3306. I want to change it to 3360.
I have tried:
-- port=3360
But things are not working for me. Please provide query to change port not any configuration. I am using Windows 8 64 bit.
You need to edit your my.cnf file and make sure you have the port set as in the following line:
port = 3360
Then restart your MySQL service and you should be good to go. There is no query you can run to make this change because the port is not a dynamic variable (q.v. here for MySQL documentation showing a table of all system variables).
If you're on Windows, you may find the config file my.ini it in this directory
C:\ProgramData\MySQL\MySQL Server 5.7\
You open this file in a text editor and look for this section:
# The TCP/IP Port the MySQL Server will listen on
port=3306
Then you change the number of the port, save the file.
Find the service MYSQL57 under Task Manager > Services and restart it.
On newer (for example 8.0.0) the simplest solution is (good choice for a scripted start-up for example):
mysqld --port=23306
When server first starts the my.ini may not be created where everyone has stated. I was able to find mine in C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.6
This location has the defaults for every setting.
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
# pipe
# socket=0.0
port=4306 !!!!!!!!!!!!!!!!!!!Change this!!!!!!!!!!!!!!!!!
[mysql]
no-beep
default-character-set=utf8
Go to installed mysql path and find bin folder,open my.ini and search 3306 after that change 3306 to 3360
Actually, you can just run the service using /mysqld --PORT 1234, it would force mysql to run on the specified port without change the cnf/ini file.
I just cought a case that cnf didn't work. It was weired... so I just use the cmd line as the shortcut and it works!
try changing the connection port to 8012
open xampp as administrator
Mysql config => my.ini change the port from 3306 to 8012
close and run it again
I hope it will work.
If you are using windows and installed the database as a service, which is the default, you should find your configuration file by opening your services management console.
For instance: win + r and then type services.msc
Look for a service called MySQL or MariaDB.
On the general tab of the properties of this service you can find a path to your mysqld.exe file and the arguments to start the exe. The --defaults-file argument should point to your configuration file.
Edit your configuration file and restart the MySQL service.
In Windows 8.1 x64 bit os, Currently I am using MySQL version :
Server version: 5.7.11-log MySQL Community Server (GPL)
For changing your MySQL port number, Go to installation directory, my installation directory is :
C:\Program Files\MySQL\MySQL Server 5.7
open the my-default.ini Configuration Setting file in any text editor.
search the line in the configuration file.
# port = .....
replace it with :
port=<my_new_port_number>
like my self changed to :
port=15800
To apply the changes don't forget to immediate either restart the MySQL Server or your OS.
Hope this would help many one.
Change my.cnf file and add this line or change it port=3360
at my fedora 34
sudo vi /etc/my.cnf
add This line ==> port=3360
The best way to do this is take backup of required database and reconfigure the server.
Creating A Backup
The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch. The process is quick and easy.
If you want to back up a single database, you merely create the dump and send the output into a file, like so:
mysqldump database_name > database_name.sql
Multiple databases can be backed up at the same time:
mysqldump --databases database_one database_two > two_databases.sql
In the code above, database_one is the name of the first database to be backed up, and database_two is the name of the second.
It is also simple to back up all of the databases on a server:
mysqldump --all-databases > all_databases.sql
After taking the backup, remove mysql and reinstall it. After reinstalling with the desired port number.
Restoring a Backup
Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database.
mysql database_name < database_name.sql
In the code above, database_name is the name of the database you want to restore, and database_name.sql is the name of the backup file to be restored..
If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this:
mysql --one-database database_name < all_databases.sql
I want to set the event_scheduler global to ON even if MySQL is restarted; how can I achieve this?
SET GLOBAL event_scheduler = ON;
You can set
event_scheduler=ON
in my.ini or my.cnf file, then restart your server for the setting to take effect.
Once set event_scheduler will always remain ON no matter whether your server restarts.
Open your /etc/mysql/my.ini file and add:
event_scheduler = on
under the [mysqld] section
(tested under mysql 5.5.35-0+wheezy1 - Debian)
One Way - You can set your system variables and use those variables if there is any possibility to restart your mysql.
Here is link Using system variables in mysql
On our Windows Server 2012 system, none of these or any other solutions worked. Then I looked at the registry entry for start up:
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
The trick, the evil, is ProgramData. It's not Program Files. Look in Program Files and you'll see a my-default.ini file, put there just to royally screw you up.
The trick is to find the path in the registry, which was for me: HKEY_LOCAL_MACHINE\SYSTEM\Services\MySQL56
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Add this line at the end of the file:
event_scheduler=ON
Than reboot and check if daemon is started after reboot:
Log into mysql bash:
mysql -u <user> -p
Than run the command:
SHOW PROCESSLIST;
Now you should see the event scheduler daemon in the list
I locked my root user out from our database. I need to get all privileges back to the root user. I have my password and I can log in to MySQL. But the root user has no all privileges.
I had the same problem as the title of this question, so incase anyone else googles upon this question and wants to start MySql in 'skip-grant-tables' mode on Windows, here is what I did.
Stop the MySQL service through Administrator tools, Services.
Modify the my.ini configuration file (assuming default paths)
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
or for MySQL version >= 5.6
C:\ProgramData\MySQL\MySQL Server 5.6\my.ini
In the SERVER SECTION, under [mysqld], add the following line:
skip-grant-tables
so that you have
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
skip-grant-tables
Start the service again and you should be able to log into your database without a password.
How to re-take control of the root user in MySQL.
DANGER: RISKY OPERATTION
Start session ssh (using root if possible).
Edit my.cnf file using.
sudo vi /etc/my.cnf
Add line to mysqld block.*
skip-grant-tables
Save and exit.
Restart MySQL service.
service mysql restart
Check service status.
service mysql status
Connect to mysql.
mysql
Using main database.
use mysql;
Redefine user root password.
UPDATE user SET `authentication_string` = PASSWORD('myNuevoPassword') WHERE `User` = 'root';
Edit file my.cnf.
sudo vi /etc/my.cnf
Erase line.
skip-grant-tables
Save and exit.
Restart MySQL service.
service mysqld restart
Check service status.
service mysql status
Connect to database.
mysql -u root -p
Type new password when prompted.
This action is very dangerous, it allows anyone to connect to all databases with no restriction without a user and password. It must be used carefully and must be reverted quickly to avoid risks.
After trying lots of things, this is what worked for me:
sudo mysql -u root
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
What that does is first we use sudo to log in mysql as root without needing a password. Then we just update root's password.
After that, I restarted mysqld:
sudo service mysql restart
And the newpassword logged root in!
On the Linux system you can do following (Should be similar for other OS)
Check if mysql process is running:
sudo service mysql status
If runnning then stop the process:
(Make sure you close all mysql tool)
sudo service mysql stop
If you have issue stopping then do following
Search for process: ps aux | grep mysqld
Kill the process: kill -9 process_id
Now start mysql in safe mode with skip grant
sudo mysqld_safe --skip-grant-tables &
I'm in windows 10, using WAMP64 server. Searched for my.cnf and my.ini. Found my.ini in C:\wamp64\bin\mariadb\mariadb10.2.14.
Following the instructions from the colleagues:
Opened the quick start menu from Wampserver, selected 'Stop All Services'
Opened my.ini in a text editor, searched for [mysqld]
Added 'skip-grant-tables' at the end of the [mysqld] section (but within it)
Save the file, leave the editor open
In the Wampserver menu, select "Restart Services'. There will be a warning about the skip-grant-tables option
In the Wampserver menu select MySQL to open the prompt
It asked for a password, just press enter
Paste the command ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
It must report that the operation was successful (no tables affected)
In the my.ini file, erase the 'skip-grant-tables' line, save the file
In the WampServer menu, select once more Restart Service
Now you can enter with the new password. Thanks to all answers here.
If you use mysql 5.6 server and have problems with C:\Program Files\MySQL\MySQL Server 5.6\my.ini:
You should go to C:\ProgramData\MySQL\MySQL Server 5.6\my.ini.
You should add skip-grant-tables and then you do not need a password.
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
# server_type=3
[mysqld]
skip-grant-tables
Note: after you are done with your work on skip-grant-tables, you should restore your file of C:\ProgramData\MySQL\MySQL Server 5.6\my.ini.
Use the following command (notice the "d"): mysqld --skip-grant-tables
if you are running on Apple MacBook OSX then:
Stop your MySQL server (if it is already running).
Find your MySQL configuration file, my.cnf. (For me it was placed #
/Applications/XAMPP/xamppfiles/etc. You can just search if you
can't find it).
Open my.cnf file in any text editor.
Add "skip-grant-tables" (without quotes) at the end of [mysqld] section and save the file.
Now start your MySQL server. It'll start with skip-grant-tables option.
Do what you want now!!
PS: Please remove skip-grant-tables from my.cnf file once you are done with whatsoever you want to do ELSE MySQL server will always run without access grants.
Please run this below command from the console to skip the user table verification while launching mysql database from command prompt
mysqld -skip-grant-tables
Edit my.ini file and add skip-grant-tables and restart your mysql server :
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql"
tmpdir = "C:/xampp/tmp"
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"
skip-grant-tables
# Change here for bind listening
# bind-address="127.0.0.1"
# bind-address = ::1
if this is a windows box, the simplest thing to do is to stop the servers, add skip-grant-tables to the mysql configuration file, and restart the server.
once you've fixed your permission problems, repeat the above but remove the skip-grant-tables option.
if you don't know where your configuration file is, then log in to mysql send SHOW VARIABLES LIKE '%config%' and one of the rows returned will tell you where your configuration file is.
This is how to do it on Ubuntu 20.4. This worked for me.
Go to /etc/mysql/mysql.conf.d/
You can write into terminal
cd /etc/mysql/mysql.conf.d/,
then you need to edit the file which is named mysqld.cnf.
On my PC, that file was a read-only file, so I needed to first change the permissions.
I wrote
sudo chmod +rw mysqld.cnf in the terminal.
After that, I edited the file by typing sudo gedit mysqld.cnf
in the terminal.
In the file, you will see [mysqld] somewhere, below [mysqld] add
skip-grant-tables in a new line, so that it looks like this
[mysqld]
skip-grant-tables
Restart the mysql service by writting sudo service mysql restart in terminal.
If your server wasn't running then write sudo service mysql start in terminal.
Another thing worth mentioning here is that
I also had another problem which I fixed in almost the exact same manner.
My server wasn't listening at the port 3306,
so I also had to add port = 3306 in that mysqld.cnf file.
Now I have
[mysqld]
skip-grant-tables
port = 3306
in the mysqld.cnf file.
I see that the question is old, but maybe my configuration will help someone. I use this configuration in scripts:
sed -i 's/^#skip-grant-tables.*/skip-grant-tables/g' /etc/my.cnf
service mysql restart
mysql -e "UPDATE mysql.user SET authentication_string='' WHERE user='root';"
sed -i 's/^skip-grant-tables.*/#skip-grant-tables/g' /etc/my.cnf
service mysql restart