Changing data directory of MySQL in Slackware

adkriPrasanna

New Member
Joined
Oct 10, 2020
Messages
3
Reaction score
1
Credits
28
Changing mysql datadirectory is getting little bit of confusing. I added the following line in /etc/my.cnf
[mysqld]
datadir=/home/user/newdir

still mysql is using /var/lib/mysql
 


f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,275
Reaction score
3,903
Credits
38,482
Did you restart mysql/mariadb?

There are usually also some files in /etc/my.cnf.d, one with the name server in it. For example mariadb-server.cnf or mysql-server.cnf, check if datadir is defined in one of those.
 
OP
A

adkriPrasanna

New Member
Joined
Oct 10, 2020
Messages
3
Reaction score
1
Credits
28
checked all the conf files. Everything is fine
but whenever i restart /etc/rc.d/rc.mysqld
it picks /var/lib/mysql

But

After searching here and there, I found something related to mysql.server file. Then i did:
cd /usr/share/mysql
./mysql.server start


Now its picking my configuration.

what is the difference between
/etc/rc.d/rc.mysqld start and
./mysql_server start

which one to choose?
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,275
Reaction score
3,903
Credits
38,482
I don't run Slackware, was thinking it should be somewhat the same over distributions. You can always try bind mounting /home/user/newdir to /var/lib/mysql that way the location doesn't matter.

I would think they are the same, wouldn't be surprised if /etc/rc.d/rc.mysqld is symlinked to /usr/share/mysqld @captain-sensible should be able to help you out here.
 
Last edited:

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,912
Reaction score
1,970
Credits
18,126
thanks invite on this. I'm not going to be much help. Thats because some time again I realistically looked at my use which is almost exclusively web development, ease of use of development and capacity i switched to sqlite3 which is written in c and is "server less" meaning its a just a file that needs no database daemon or what ever you want to call it; it has a capacity of 281 terabytes which i doubt i'm going to exceed with blogs etc

i used to go through the pain of MySQl grant all options, web on one sever and database on another , users etc and having to use phpMyAdmin etc all all the other quirks and grief and just thought why put put myself through it.

So for instance for php i can work from the Desktop just using built in server, play with php code and still use a databse or as i usually do develop in apache with a few projects via virtual host settings
One issue with sqlite3 is maybe security but then the file is outside what can be accessed from the web; so you should be able to download it. Passwords are hashed.

People use Mysql with wordpress; the admin password, Slug and display name are stored in a table called users; the fact that it uses MySQl doesn't stop me getting the user name from the database quite easily in a lot of cases !

I can browse the database just using sqlitebrowser. IN short what ever i knew about MySQl or Maria i forgot. If i were a mod on here i wouldn't advertise places where you might get help away from this forum but if its ok with them i can suggest that .

@adkriPrasanna Don't right us off completely here on Slackware for other issues.

i have alterted another Slackware user on here to see if he can shed any light @VP9KS
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,275
Reaction score
3,903
Credits
38,482
Thanks for replying @captain-sensible OP got it working he just was confused about the different startup files of mysqld. I thought you could maybe help out with that part since you have experience with Slackware and how the startup of processes exactly works there.
After searching here and there, I found something related to mysql.server file. Then i did:
cd /usr/share/mysql
./mysql.server start


Now its picking my configuration.

what is the difference between
/etc/rc.d/rc.mysqld start and
./mysql_server start

which one to choose?
My guess was that /etc/rc.d/mysqld is symlinked to /usr/share/mysql or something like that. I would think that doesn't matter what you have installed that needs to startup that basic idea is the same, so I thought you could help the OP figure out the difference between the different startup files in the two locations OP mentioned.
 
Last edited:

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,912
Reaction score
1,970
Credits
18,126
Will have a look at anything related to slackware :^) can't always help though ! to make it work Slackware is changing @adkriPrasanna which version of slackware are you using 14.2 or current ?
 

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,912
Reaction score
1,970
Credits
18,126
checked all the conf files. Everything is fine
but whenever i restart /etc/rc.d/rc.mysqld
it picks /var/lib/mysql

But

After searching here and there, I found something related to mysql.server file. Then i did:
cd /usr/share/mysql
./mysql.server start


Now its picking my configuration.

what is the difference between
/etc/rc.d/rc.mysqld start and
./mysql_server start

which one to choose?
Slackware uses BSD style for its init . All of the system initialization files are at /etc/rc.d

thus:
/etc/rc.d/rc.httpd
i.e apache
there are some odd quirks with some scripts about the place which were supposed to be used as a starting point. There used to be cnf large, huge last time i used MySQl you chose one.

They used to do things like :

Code:
cp  /usr/share/mysql/mysql.server       /etc/rc.d/rc.mysqld

So there is some sort of legacy stuff lying around linking to how they used to do things.


Once /etc/rc.d/rc.mysqld has had exec permissions of
chmod a+x /etc/rc.d/rc.mysqld

set only needs doing once , then that daemon wills automatically when computer boots. So you really need make its picking up config without firing up any other script.
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,275
Reaction score
3,903
Credits
38,482
OP
A

adkriPrasanna

New Member
Joined
Oct 10, 2020
Messages
3
Reaction score
1
Credits
28
Thanks for your help, I'm using Slackware 14.2, actually my main problem was to change the data directory of MySQL Server
I copied the contents of /var/lib/mysql to home directory and edited rc.mysqld
I modified the line having --datadir=/var/lib/mysql to --datadir=/home/my-path
Now its fine.
But I don't know is it good practice to edit rc.mysqld or editing my.cnf is preffered...
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Latest posts

Top