LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-26-2008, 04:23 AM   #1
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Rep: Reputation: 37
mysql is in /var/lib/mysql/[database]....how to transfer to my username?


Hi Keen Fellowman!

Currently mysql data is in /var/lib/mysql/[database] i want to transfer the data to my username coz currently it was owned by mysql in /var what am I going to do?

edit /etc/my.cnf? and put the database location inside?

how about ownership and permission?
thanks
 
Old 11-26-2008, 04:59 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,497

Rep: Reputation: 90
Not sure what you mean, but you can change ownership for files in a directory by logging in as root and doing

chown -R username.username directoryname

in a terminal

where

username = your username
directoryname = the name of the directory.

This should change the directory itself as well as the files it contains to the username you specify.
 
Old 11-26-2008, 05:52 AM   #3
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by rylan76 View Post
Not sure what you mean, but you can change ownership for files in a directory by logging in as root and doing

chown -R username.username directoryname

in a terminal

where

username = your username
directoryname = the name of the directory.

This should change the directory itself as well as the files it contains to the username you specify.
If I change ownership supposed it is in /var/lib/mysql directory the increasing bytes consumed on my HDD are owned by /var/lib/mysql or by my [username]? /usr/home/nnnnname

what I want is to avoid /var to become full? I am running out of space in /var but my /usr/ is 100+G.

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup_ID_17452-LogVol1
1008M 206M 752M 22% /
/dev/sda3 190M 15M 166M 8% /boot
none 2.0G 0 2.0G 0% /dev/shm
/dev/mapper/VolGroup_ID_17452-LogVol2
496M 15M 457M 4% /tmp
/dev/mapper/VolGroup_ID_17452-LogVol5
154G 3.1G 143G 3% /usr
/dev/mapper/VolGroup_ID_17452-LogVol4
496M 359M 112M 77% /var
/dev/mapper/VolGroup_ID_17452-LogVolHome
123G 5.0G 112G 5% /home

because of a lots of log files in apache, php, mysql, oracle, 3rd party...etc..etc...running simultanously my /var is easy to become out of space.

what am I going to do?
 
Old 11-26-2008, 11:23 AM   #4
paul.fisher
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
If limited space in /var is the only consideration, then you should resize your partitions. You DON'T want to start messing with the ownership of MySQL files. You will create more problems than you solve by doing so. Further, simply changing ownership will not solve your space issue, even if you "own" the files they will continue exist and take up space in /var
 
Old 11-26-2008, 09:25 PM   #5
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by paul.fisher View Post
If limited space in /var is the only consideration, then you should resize your partitions. You DON'T want to start messing with the ownership of MySQL files. You will create more problems than you solve by doing so. Further, simply changing ownership will not solve your space issue, even if you "own" the files they will continue exist and take up space in /var
can you help me how to resize my partition?

http://www.linuxquestions.org/questi...780/page2.html
 
Old 11-26-2008, 09:37 PM   #6
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Why not just edit my.cnf and change the location of your datafiles. You may have to do a mysqldump in order to move the database. However simply changing the permissions will not fix anything but most likely break the database.
 
Old 11-26-2008, 09:43 PM   #7
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by jstephens84 View Post
Why not just edit my.cnf and change the location of your datafiles. You may have to do a mysqldump in order to move the database. However simply changing the permissions will not fix anything but most likely break the database.
can you give me the step by step procedure buddy.

Last edited by RMLinux; 11-26-2008 at 09:46 PM.
 
Old 11-26-2008, 09:48 PM   #8
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Code:
mysqldump [database name] > [dump file name]
all this does is make a backup of the database. so then you would edit the my.cnf file, change the database location, then recreate the mysql database using mysqldump again. However before you do this please check the syntax of this command and make sure that everything looks ok. especially if this is on a live server.
 
Old 11-28-2008, 09:15 AM   #9
paul.fisher
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by RMLinux View Post
can you help me how to resize my partition?

http://www.linuxquestions.org/questi...780/page2.html
I've used the GParted live CD to modify partitions. See the tutorial at: http://www.howtoforge.com/partitioning_with_gparted
 
Old 11-29-2008, 11:39 AM   #10
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by RMLinux View Post
can you give me the step by step procedure buddy.
Here is a high level step by step procedure. However again do your research and I nor LQ are responsible for lost data. Now without further adieu

1. do a mysql dump on your databases
2. stop mysql
3. move database files to new location
3. edit my.cnf to point to where new database files are located.
4. start mysql.
5. Connect to mysql and check each database for data integrity.

Again exercise extreme caution. And do not change any permissions on the database files. If you do mysql will surely throw a fit. If this is a live server I recommend that you do an image of the server for a full backup. If it is a test server than I would be kind of concerend. But I am guessing that this is a production server.
 
Old 11-30-2008, 12:31 AM   #11
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Original Poster
Rep: Reputation: 37
Smile

Quote:
Originally Posted by jstephens84 View Post
Here is a high level step by step procedure. However again do your research and I nor LQ are responsible for lost data. Now without further adieu

1. do a mysql dump on your databases
2. stop mysql
3. move database files to new location
3. edit my.cnf to point to where new database files are located.
4. start mysql.
5. Connect to mysql and check each database for data integrity.

Again exercise extreme caution. And do not change any permissions on the database files. If you do mysql will surely throw a fit. If this is a live server I recommend that you do an image of the server for a full backup. If it is a test server than I would be kind of concerend. But I am guessing that this is a production server.
Thanks for you reply dud.

here's my etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid




can you edit for me supposed I
want to save my database in username [foo].

/home/foo -- this is the username

how about the permission, ownership, socket, basedir?

anything that are possible to change kindly fill it up. thanks
 
Old 11-30-2008, 12:36 AM   #12
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
you would change the datadir to /home/foo/. However you don't really need to change the permissions on the datafile as that will not restrict grow. Again just migrate the databases to a new partition with more space. Another suggestions could be to try and compact your databases.
 
Old 11-30-2008, 08:45 PM   #13
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by jstephens84 View Post
you would change the datadir to /home/foo/. However you don't really need to change the permissions on the datafile as that will not restrict grow. Again just migrate the databases to a new partition with more space. Another suggestions could be to try and compact your databases.
I change datadir=/home/foo/mysql on my.cnf.
I restart my mysql and it works fine still I can create transaction.

The thing is it seems it is using the same old database the database in /var/lib/mysql because I add transaction on the foo/ settings and I shutdown my database I edited my.cnf and return to old settings the transaction that I created still appeared on the old database?

Why?
 
Old 11-30-2008, 10:20 PM   #14
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Not really sure. Try changing your basedir also just to see if that would work. But I don't think that would matter. Try adding a new database and see where the location for the database file goes.
 
Old 11-30-2008, 11:35 PM   #15
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
There is an argument that you can pass on the command line to change the data directory. That will override the setting in my.cnf.

Check how mysql is started.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 03:13 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Software 3 06-28-2007 12:46 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 04:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 09:44 AM


All times are GMT -5. The time now is 01:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration